InstallShield 2015 » InstallScript Language Reference

Project: The following project types support the DotNetCoCreateObject function:

InstallScript MSI
Basic MSI with InstallScript custom actions

The DotNetCoCreateObject function calls functions in .NET assemblies without the assembly being registered for COM interoperability. This function lets you specify the .NET application domain in which the .NET assemblies should be loaded and run. Each object created with this function is associated with a single class in a single .NET assembly. If you want to access multiple classes in the same assembly, you must create a separate object for each class.

Important: The assembly does not have to be registered as a COM component, but the assembly must be built to be compatible with COM interoperability. Assemblies built with Visual Studio .NET 2003 and earlier are automatically built with this compatibility. However, projects created with Visual Studio 2005 must manually specify [assembly: ComVisible(true)] in the appropriate file.


DotNetCoCreateObject ( byval string szAssemblyPathFile, byval string szAssemblyAndClassName, byval string szAppDomain );


DotNetCoCreateObject Parameters




Specifies the full path and file name of the .NET assembly that contains the appropriate class.


Specifies the assembly and class name.

Note: This value is the same as the szProgId parameter if the assembly is registered for COM interoperability using the CoCreateObject function.


Specifies the .NET application domain to load and run the assembly in. If the specified application domain does not exist in the installation process, it is created; otherwise, the existing application domain is used. This is true if you call DotNetCoCreateObject multiple times with the same szAppDomain.

If you specify a null string ("") for this parameter or call CoCreateObjectDotNet instead of DotNetCoCreateObject, the assembly is loaded into the default application domain after the installation completes; thus, the .NET assembly file is locked until the installation has finished.

For more information on .NET application domains, see the .NET Framework Developer’s Guide in the MSDN Library.

Return Values

The reference can be assigned to a variable of type OBJECT by using the set keyword.

Additional Information

The DotNetCoCreateObject function is similar to the CoCreateObjectDotNet function. The only difference is that with DotNetCoCreateObject, you can specify the .NET application domain that should be loaded; the assembly is then run in this domain.

For CoCreateObjectDotNet, the .NET assembly is loaded into the default application domain after the installation completes; thus, the .NET assembly file is locked until the installation has finished.

Any object variable can be released by setting the object variable to the value of NOTHING or reassigning the object with the CoCreateObject, CoCreateObjectDotNet, CoGetObject, or DotNetCoCreateObject functions. However, this does not automatically unload the library referenced by the object. You must call the Windows API CoFreeLibrary manually to free the library. Otherwise, the library remains loaded until the installation finishes. For more information, see Extending Your Installation with COM Objects.
This function throws an exception if the object cannot be created. This can occur if the .NET Framework is not installed on the system, or for other reasons. To handle this exception, surround calls to this function with try...catch blocks. For more information, see Exception Handling.

See Also