cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Register Assembly (RegAsm.exe) for both 32 & 64 bit using a custom action

Register Assembly (RegAsm.exe) for both 32 & 64 bit using a custom action

Summary

This article provides information about .Net assembly registration when installing setups using Windows Installer and RegAsm.exe.

Synopsis

This article is intended to provide information on working with .Net assembly registration when installing setups using Windows Installer.


Discussion

The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. When you register an assembly for use by COM, Regasm.exe adds entries to the registry on the local computer.

Under normal use of InstallShield during the build process, InstallShield calls the Microsoft file RegAsm.exe on the .NET .dll to create a registry (.reg) file. This occurs when the .NET COM Interop property in the component is set to 'Yes'. During build a .reg file is created and the .reg file is imported. The resulting registry entries are then stored in the Registry table of the MSI database.

?Using custom code to manually execute the RegAsm.exe tool to register the assembly involves more than one version of this tool based on Operating System:

? C:\Windows\Microsoft.NET\Framework\<FrameWorkVersion>\RegAsm.exe
? C:\Windows\Microsoft.NET\Framework64\<FrameWorkVersion>\RegAsm.exe

Please refer to .NET functionality RuntimeEnvironment.GetRuntimeDirectory() static method in an effort to return the FrameWorkVersion number and/or the path of the common language runtime.


In the event custom actions to call RegAsm.exe are not possible consider creating the Reg file outside of InstallShield as a pre-build process and consume the resulting Reg file at build. The Microsoft article Regasm.exe (Assembly Registration Tool) describes what switch to pass on the cmd to create the Reg file. The Import REG File Wizard can be used to import a .reg file into a component or registry set, that registry data is added to the component?s or registry set?s registry data and written to the end user?s system if the component or registry set is installed.

Related Documents

Regasm.exe (Assembly Registration Tool)

LaunchApplication()

Import REG File Wizard


Related KB Articles

Launch an Executable Using a Custom Action

Additional Information

An overview of steps involved include:

- Use the InstallScript method LaunchApplication() in a custom action in a 64-bit installer while manifesting the setup.exe to provide Administrative Privilege is an approach to run the 64 bit version of RegAsm against the .Net assembly.

- Ensure the .Net dll to be registered is managed code and COM visible.

- Include the resulting InstallScript Custom Action in the Execute sequence and set for Deferred Execution. In deferred mode system changes described by an internal installation script between the built-in actions InstallInitialize and InstallFinalize. Schedule the deferred action between InstallInitialize and InstallFinalize.

- Condition the action to run against x64 systems. A common Windows Installer property to use as the condition is: VersionNT64.

- Create, schedule, condition and maintain a similar custom action for the x86 RegAsm.exe.
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Jul 19, 2018 04:35 PM
Updated by: