Search code examples
wixwix3.5wix3.6dllregistration

Error while registering .dll to COM


I have a COM library that I want to register in COM during Wix installation.

At first, I tried to harvest information using heat command, but nothing was harvested from that .dll. Then I supposed my library was wrong and tried to install it manually using regsvr32 command like this:

regsvr32.exe /s "RouteToMyLibrary/MyLibrary.dll"

And it did install correctly...

Then I decided to install the .dll using a CustomAction instead of harvesting as it looked as a solution for me.

So I wrote the following CustomAction:

 <CustomAction Id="RegisterCOMLibrary" 
               Directory"DirIdOfWhereMyComLibraryIsLocated"
               ExeCommand='regsvr32.exe /s "[DirIdOfWhereMyComLibraryIsLocated]MyLibrary.dll"'></CustomAction>

<InstallExecuteSequence>
    <Custom Action="RegisterCOMLibrary" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>

But then, when I run my installer it launches 1722 mistake.

I run the installer writing a log.txt like this:

msiexec /i MyInstaller.msi /l*v log.txt

And I can see that 1722 mistake. Notes:

  • The directory path points to the correct place
  • If I exctract the regsvr32 command from the log and try to execute it, IT DOES REGISTER the COM library.

Any idea on what I'm doing wrong and why I can't register my .dll using this automated CustomAction from Wix?

NOTE: When I do heat file mylibrary.dll -out mylibrary.wxs it says:

Could not harvest data from a file that was expected to be a SelfReg DLL...

Solution

  • Looks like there is either something wrong with your COM dll, or it has lacking dependencies that prevents it from loading via heat.exe. Two tools that can help: dependency walker and regspy:

    RegSpy (Freeware from Phil Wilson and others, download from Stefan Kruger's http://installsite.org/ . The tools page.):

    Dependency Walker (Freeware from Steve Miller):

    First try RegSpy to determine if it can extract the com data from the dll. If this doesn't work use the Dependency Walker to check if there are missing dependencies that prevent the dll from loading. These could be other dll's or even resource files such as images or language dll's which are resource only (and with images sometimes).

    Depending on the results of running these two tools you may need to fix something in your dll, or just perform the com data extraction properly with all dependencies in place.

    Note that some COM files do really crazy things during registration - such as changing the network parameters of TCP/IP or God knows what else. Rare to see, but a serious design error of the COM component. RegSpy can reveal this, but most often it is seen if you repackage applications.