9

If not self registering. then how do we perform the COM dll registering while installation using WIX?

As per the tutorial, I used ComPlusApplication example (non .net dll). But its not working. It fails to register.

I can register using regsvr32 from the command line successfully. I read about not creating custom actions for registering com dlls.

SO what is the best approach? If we need to use heat, where do we write the commands and add the result wxs to the main project?

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
rakheep
  • 95
  • 1
  • 4
  • Although you asked for a way to register you could consider to not register the COM components. The registration free COM models allows you to use COM dlls without touching the registry at all. See: http://msdn.microsoft.com/en-us/library/ms973913.aspx – harper Nov 05 '14 at 09:53

2 Answers2

20

I would strongly recommend using the Wix tool Heat.exe to harvest all the data needed to register the com component and then reference the fragment in your .wxs file like this:

    <ComponentGroupRef Id="FooBar.dll" />

Or include it in your .wxs file like this:

    <?include FooBar.dll.wxi?>

This method gives you full control over what happens during the registration/Unregistration of the Com component.

You can however still use Regsvr32 in a Wix project. But it relies on the correct implementation of the RegisterServer/UnregisterServer functions in the COM component

    <CustomAction Id="RegisterFooBar" 
                  Directory="INSTALLDIR" 
                  ExeCommand='regsvr32.exe /s "[INSTALLDIR]FooBar.dll"'> 
    </CustomAction> 
    <CustomAction Id="UnregisterFooBar" 
                  Directory="INSTALLDIR" 
                  ExeCommand='regsvr32.exe /s /u "[INSTALLDIR]FooBar.dll"'> 
    </CustomAction>

Then add your action to the install sequence.

    <InstallExecuteSequence> 
        <Custom Action="RegisterFooBar" After="InstallFinalize">NOT Installed</Custom>
        <Custom Action="UnregisterFooBar" After="InstallFinalize">REMOVE="ALL"</Custom>
    </InstallExecuteSequence>
A.Game
  • 459
  • 4
  • 16
  • I used heat tool to generate and then copied the output to my .wxs file. – rakheep Jun 14 '12 at 10:40
  • @rakheep: If you find an answer useful, please upvote it. When you have received one or more correct answers, please select the best one as answer. – JOG Jul 25 '12 at 08:29
  • Looks like the unregister command is missing in your post above. Also I had to use this method when I couldn't extract the registry information using heat for 1 particular dll. Worked for all but 1 in a particular project. – Cole W Jun 20 '14 at 20:39
  • @ColeW I added the unregister command, thank you! Here is another trick I learned when dealing with self registering dlls. If you manage to find a msi or an msm that installs said dll (ex. from the third party distributor, you could use the Dark.exe Wix tool to extract a .wxs file describing the msm. Then you could look for the description of your desired dll there. – A.Game Nov 05 '14 at 08:50
  • Using a custom action looks elegant at first. But it relies on the correct implementation of the RegisterServer/UnregisterServer functions in the COM component. The more secure way is creating the registry information with `heat -gg`. I suggest to emphasis what looks like a side note in your answer. – harper Nov 05 '14 at 09:55
  • @harper Thank you for the feedback! I edited the answer to reflect that I suggest using heat first – A.Game Nov 05 '14 at 15:08
  • @A.Game - just an opinion - in the `InstallExecuteSequence` the Unregister action should not have the Before attribute? In my case the file were gone and the unregister gave an error. – Edi May 10 '19 at 12:31
2

You could try to use the heat.exe program, and then reference the fragment in your wix code.

heat.exe file -gg -out

As in:

heat.exe file my.dll -gg -out my.wxs

Ps. Adding -gg switch will generate the guids, else you can skip it if you want to manually add them.

whihathac
  • 1,741
  • 2
  • 22
  • 38