Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you register a Win32 COM DLL file in WiX 3?

Tags:

dll

com

wix

wix3

I found an example on registering DLLs, Registering an Assembly for COM Interop in a MSI file with the Windows Installer XML toolset., and WiX complains about the "AssemblyRegisterComInterop" attribute.

I removed that and changed the "Assembly" attribute to win32, and it says I need to specify the AssemblyManifest attribute, but what should I put there?

like image 842
Davy8 Avatar asked Dec 12 '08 21:12

Davy8


People also ask

How do I manually register a DLL?

Register 32 or 64-bit DLLs in Windows Step 1: First click on Start, then Run. Step 2: Now all you have to do to register a DLL file is to type in the regsvr32 command, followed by the path of the DLL file. Step 3: Now click OK and you should get a confirmation message that the DLL has been registered successfully.

How do I register a DLL file in Windows 10 32 bit?

Click Start > All Programs > Accessories and right-click on "Command Prompt" and select "Run as Administrator" OR in the Search box, type CMD and when cmd.exe appears in your results, right-click on cmd.exe and select "Run as administrator" At the command prompt, enter: REGSVR32 "PATH TO THE DLL FILE"


2 Answers

The easiest way (and Rob M will rant and rave about how this is wrong) is just to use SelfRegCost=1 on the File tag for the DLL.

This is wrong, because we should be explicitly controlling the registration of the DLL, not allowing it just to run arbitrary code via DllRegisterServer. The theory being that a DLL should do nothing beyond putting the appropriate entries in the registry when DllRegisterServer is called. Unfortunately, a lot of of them do more than that, so self-registration might be the only way to get your install to work.

It's also wrong, because that means the Windows installation system doesn't know anything about those registry keys, and what should and shouldn't be there. That means repairing won't work, and possibly un-installation won't clean up properly, etc.

Otherwise, you can generate the appropriate WiX code by pointing heat.exe at your DLL, and integrating its output into your current WiX project. You'll get a variety of Class, ProgID, TypeLib, and Registry tags. You may need to manually edit that output to get it to compile.

I hope that helps.

like image 109
Troy Howard Avatar answered Sep 25 '22 01:09

Troy Howard


It isn't just me that will rant and rave about how SelfReg is evil. The MSI SDK gives you a list of seven reasons why not to use SelfReg.

Example:

<Component Id="Component" Guid="*">     <File Source="ComServer.dll">         <Class Id="PUT-CLSID-HERE" Context="InprocServer32" ThreadingModel="apartment" Description="Your server description">             <ProgId Id="Your.Server.1" Description="Your ProgId description">                 <ProgId Id="Your.Server" Description="Your ProgId description" />             </ProgId>         </Class>          <Class Id="PUT-PROXY-CLSID-HERE" Context="InprocServer32" ThreadingModel="both" Description="Your server Proxies, assuming you have them">             <Interface Id="PUT-INTERFACEID-HERE" Name="IInterface1" />             <Interface Id="PUT-INTERFACEID-HERE" Name="IInterface2" />             <Interface Id="PUT-INTERFACEID-HERE" Name="IInterface3" />             <Interface Id="PUT-INTERFACEID-HERE" Name="IInterface4" />         </Class>     </File> </Component> 

Ultimately, Troy's answer is all correct.

like image 41
Rob Mensching Avatar answered Sep 21 '22 01:09

Rob Mensching