Using CoCreateObjectDotNet to Access and Use .net Assemblies in InstallScript
2011年04月18日
http://kb.flexerasoftware.com/selfservice/viewCont ent.do?externalID=Q112220 Q112220: CODE: Using CoCreateObjectDotNet to Access and Use .NET Assemblies in InstallScript InstallShield 11.5 Premier, InstallShield 11.5 Professional, InstallShield 12 Premier, InstallShield 12 Professional, InstallShield 2008 Premier, InstallShield 2008 Professional Basic MSI, InstallScript MSI CoCreateObjectDotNet calls functions within assemblies that are creating using .NET. CoCreateObjectDotNet creates an object that references a method of a .NET assembly. Each method you wish to use will require a separate call into CoCreateObjectDotNet. Note: Assemblies built with Visual Studio 2005 require that the attribute ComVisible be set to true for each class that will be called from CoCreateObjectDotNet. The code below demonstrates a sample implementation of CoCreateObjectDotNet assuming you've created a DLL using .NET 2.0 that has a class named OutputInfo with the method DisplaySystemInfo(). try
set dotNet = CoCreateObjectDotNet(SUPPORTDIR ^ "SampleClass.dll","SampleClass.OutputInfo");
dotNet.DisplaySystemInfo();
catch
SprintfBox(INFORMATION,"CoCreateObjectDotNet Error","ERROR: %s NUMBER: %d",Err.Description,Err.Number);
endcatch;
For additional help with the ComVisible attribute, please reference MSDN article ComVisibleAttribute Class. For additional information on InstallScript, see the InstallScript Language Reference in the InstallShield Help Library. Last Modified Date: 11-30-2009ID: Q112220 STEP 1. Create the DLL
using System;
using System.Runtime.InteropServices;
namespace ViewerCentral
{
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[Guid("4E0697CB-209A-40c5-939D-709924CC9AFB")]
public class IISUtils: I_IISUtils
{
public IISUtils() {}
public string GetStringSites()
{
return "Test";
}
}
[Guid("B464E841-D49A-4f5b-8701-0C40544CF110")]
public interface I_IISUtils
{
string GetStringSites();
}
}
Several notes here:
- Don't return to InstallScript complex classes or objects, but only simple types that can be recognized, like ( int, string, etc.).
- NO registration for COM Interop is necessary, however, as you see the DLL must be in the COM Interrop format.
STEP 2. Use DLL in InstallScript
1. Add your DLL to Support Files (I have added it to Language Independent).
2. Define a path to the DLL:
#define DLL_FILE SUPPORTDIR ^ "IISUtils.dll"
3. Use the DLL by calling one of its methods.
object oIISUtils;
string szSites;
set oIISUtils = CoCreateObjectDotNet( DLL_FILE, "ViewerCentral.IISUtils" );
szSites = oIISUtils.GetStringSites();
Hope this helps pull this out faster. This certainly worked for me. Good Luck!
发表评论
-
数据库设计
2012-01-20 02:48 575数据库设计 2011年01月12日 1.1 项目目的 ... -
CPPUNIT使用说明
2012-01-20 02:48 1329CPPUNIT使用说明 2010年08月04日 CPPU ... -
安装单服务器版的Team Foundation Server
2012-01-20 02:48 834安装单服务器版的Team Fo ... -
VS2008 AddIn 开发 WorkspaceAddIn 实例(支持VS2010)
2012-01-20 02:48 879VS2008 AddIn 开发 WorkspaceAddIn ... -
神马都不是浮云
2012-01-19 10:41 640神马都不是浮云 2012年01月17日 心理准备每天都应 ... -
曾经神马梦想都是浮云!学校一切我伤不起你们,你们如何伤得起我?
2012-01-19 10:41 608曾经神马梦想都是浮云! ... -
神马都是浮云!
2012-01-19 10:41 555神马都是浮云! 2012年01月13日 兔年的201 ... -
珍惜自己
2012-01-19 10:41 596珍惜自己 4小时前 原始 -
完成端口的一些问题
2012-01-17 03:11 596完成端口的一些问题 2010年11月23日 测试完成端口 ... -
2011-9-13
2012-01-17 03:11 4762011-9-13 2011年09月13日 JavaSE ... -
如何保护自己的共享软件
2012-01-17 03:11 575如何保护自己的共享软 ... -
【转】C/C++ 面试题集锦
2012-01-17 03:11 1049【转】C/C++ 面试题集锦 2011年07月10日 1 ... -
c 试题
2012-01-17 03:11 1801c 试题 2010年06月02日 .1 若a、b、c、d ... -
团队口号
2012-01-16 01:45 1182团队口号 2010年01月06日 查看文章 口号大 ... -
激励口号
2012-01-16 01:45 610激励口号 2011年02月16日 ... -
行业的激励口号
2012-01-16 01:45 753行业的激励口号 2010年0 ... -
激励口号集锦
2012-01-16 01:44 675激励口号集锦 2009年07月18日 激励口号集锦增员类 ... -
团队精神训练团队口号精神口号团队心声营销口号知道口碑营销
2012-01-16 01:44 1085团队精神训练团队口号 ... -
ASP创建xml
2012-01-11 01:33 512ASP创建xml 2011年09月01日 Dim xml ... -
从实际出发
2012-01-11 01:33 563从实际出发 2011年09月01日 记得前几天看 ...
相关推荐
Assemblies <br>Direct Use of DLLs Private Assemblies Global Assemblies Compile/Link Cycle View Assemblies - The Intermediate Language Disassembler (ILDASM) <br>4. Sample Application...
Learn how to convert existing .NET code to work on multiple platforms or how to start new projects with knowledge of the tools and capabilities of .NET Core. Purchase of the print book includes a ...
Assemblies <br>Direct Use of DLLs Private Assemblies Global Assemblies Compile/Link Cycle View Assemblies - The Intermediate Language Disassembler (ILDASM) <br>4. Sample ...
This new 7th edition of Pro C# 6.0 and the .NET 4.6 Platform has been completely revised and rewritten to reflect the latest changes to the C# language specification and new advances in the .NET ...
Whether you are moving to .NET for the first time or are already writing applications using previous .NET versions, this book will provide you with a comprehensive grounding in the new technology and ...
Now in its 8th edition, you’ll find all the very latest C# 7.1 and .NET 4.7 features here, along with four brand new chapters on Microsoft’s lightweight, cross-platform framework, .NET Core, up to ...
Whether you are moving to .NET for the first time or are already writing applications using previous .NET versions, this book will provide you with a comprehensive grounding in the new technology and ...
The mission of this text is to provide you with a rock-solid foundation in the C# programming language and the core aspects of the .NET platform (assemblies, remoting, Windows Forms, Web Forms, ADO...
Prentice.Hall.Application Development Using Csharp And .Net.chm Build industrial-strength .NET applications with C#! <br> Practical, useful information on the .NET Framework, the Common ...
Everything you need to put .NET 3.5 and C# 2008 to use in your professional work--before anyone else! Insights and techniques from the author's experience since .NET 1.0 Complete coverage of .NET ...
This new 7th edition of Pro C# 6.0 and the .NET 4.6 Platform has been completely revised and rewritten to reflect the latest changes to the C# language specification and new advances in the .NET ...
.NET Reflector enables you to easily view, navigate, and search through, the class hierarchies of .NET assemblies, even if you don't have the code for them. With it, you can decompile and analyze .NET...
This code is for accesing nonvisual objects of .net in Power Builder
The mission of this text is to provide you with a rock-solid foundation in the C# programming language and the core aspects of the .NET platform (assemblies, remoting, Windows Forms, Web Forms, ADO...
and validate user input •Use OOP techniques, including encapsulation and method overloading •Build custom controls and .NET assemblies •Access and modify data using XML, Microsoft ADO...
The Visual Studio add-in also includes .NET Reflector Pro, which allows you to seamlessly debug into third-party code and assemblies, even if you don't have source code for them. You can now treat the...
In contrast to obfuscators .NET Reactor completely stops any decompiling by mixing any pure .NET assembly (written in C#, VB.NET, Delphi.NET, J#, MSIL...) with native machine code. In detail, .NET ...
Reflector for .NET ....Net Reflector is the class browser, explorer, analyzer and ... Reflector allows to easily view, navigate, search, decompile and analyze .NET assemblies in C#, Visual Basic and IL.