tags:

views:

133

answers:

1

I've got a vanilla .net class library which contains some types which are [ComVisible] and the assembly itself is marked "Register for COM Interop". I'm trying to build a WIX installer for the app which will need to not only copy the .net assembly to the INSTALLATIONDIR on the target machine, but also do the work of registering that the object so that some legacy VB6 applications can make use of the .net assembly.

I've been using heat.exe (the heat file task more precisely) to harvest a fragment which I've included via a componentGroupRef in my main wix file. My question is should the file that heat.exe is harvesting be the .tlb file output by my class library or the dll itself? If I use heat.exe on the .tlb I dont get any registry elements in the fragment but I do with the dll. If I ought to be using the dll what role does the .tlb play in this process?

Im using the below heat task in msbuild

<HeatFile
  NoLogo="true"
  ToolPath="$(WixToolPath)"
  TreatWarningsAsErrors="false"
  AutogenerateGuids="true"
  GenerateGuidsNow="true"
  OutputFile="$(MSBuildProjectDirectory)\fragments\DemoTypeLib.wxs"
  File="$(SolutionDir)DemoClassLibrary1\bin\Debug\DemoClassLibrary1.dll"
  ComponentGroupName="DemoTypeLibComponent"
    PreprocessorVariable="var.DemoClassLibrary1.TargetDir"
  SuppressCom="false"
    DirectoryRefId="INSTALLLOCATION"
  SuppressRegistry="false"
  SuppressRootDirectory="true" />
A: 

Just ship the Fragment with the DLL and the COM for it. You don't need the TLB.

Christopher Painter
Hi Christopher. from your answer I take it I need to use heat to harvest the dll rather than the tlb? And I just add the generated fragment to my main wix file?
Dav Evans
Correct. A couple of gotchas to watch out for. Sometimes Heat ( and tools from other vendors like it ) will fail to extract some of the needed COM registry values. This would seem next to impossible based on how much meta data is in a .NET assembly but it's due to the fact that any user code in your class doesn't get called when you do a gacutil /regfiles. See the MSDN gacutil help topic for evidence of that.
Christopher Painter
If it doesn't work on your target machine, use a program like InstallWatch to snapshot the registry; run gacutil and do another snapshot / difference report to see any changes that were made. If you find anything relevant manually author that into your fragment and rebuild / redeploy. COM is a pain and sometimes tricky but once it stabilizes you should be fine.
Christopher Painter
Hi Christopher, I've used heat across my "registered for COM" dll and it produced a wxs fragment that contained registry entries. I included this fragment into my main wix file via a componentGroupReg and once complied I installed the msi on my dev machine. However I'm bot convinced the dll is registered for COM If I open the VB6 IDE, I cannot see my dll in the list of objects to make a reference to. Any ideas?
Dav Evans
Does it start working if you manually call regasm after running the install? If it does, then follow my advise above. If it doesn't, COM/VB6 had a concept of early binding and late binding. Some COM servers couldn't be used as designer addins. That's the limit of my historical knowledge though.
Christopher Painter
Still cannot get this to work. Thanks for your help anyway.
Dav Evans
I would ignore the installer issues for the moment and see if you can come up with a "manual" process for copying and registering the files. It could be that or that your COM isn't written in the right way to support what you are trying to do. Once you get that working then we can revist the installer to translate your manual process into WiX / MSI details.
Christopher Painter