Announcement

Collapse
No announcement yet.

Registering .Net DLL for COM interface

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Registering .Net DLL for COM interface

    I found an old post for this from 2009 here. I was wondering if there is an easy way to accomplish this in the newest version of MSI Factory. I basically need this command line to be executed after .NET 2.0 is installed and the dll and tlb have been copied into the INSTALLDIR:

    Code:
    %WINDIR%\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe WinSCPnet.dll /codebase /tlb:WinSCPnet32.tlb
    Do I just write a custom action? Or are there settings on the Registration tab for WinSCPnet.dll, that will cause the command line above to get executed?

  • #2
    I contributed to that post some years ago, and today I would approach this differently. Instead of using the external RegAsm.exe, I would use a WiX fragment and insert this into the source. This WiX fragment would be the result of the harvester, heat, called in a command similar to this:

    Code:
    ...\heat.exe file control.tlb -out TlbHarvest.wxs -cg Tlb -ag -dr INSTALLDIR
    ...\heat.exe file control.dll -out DllHarvest.wxs -cg Dll -ag -dr INSTALLDIR
    This can be done as part of the pre-build steps. Once you have the WiX fragments, you could include them as the "Last Child" of the feature...

    Ulrich

    Comment


    • #3
      Thanks, I was able to run heat.exe and generate the wxs files. I'm am not sure how to use these wxs files in the project. Could you help me out with that part? Do you use "Add files" to include them in the project? Then what?

      EDIT: I think I found it. Under Build Settings -> Fragments.
      Last edited by PPro; 10-06-2015, 04:23 PM. Reason: Found answer

      Comment


      • #4
        In the "Fragment Insertion Properties" dialog, I chose Insertion Type: Last Child. What do I fill in for "Target search string" and "Text to Insert"? Build Files.zip

        Comment


        • #5
          Hello, could you share the project file? If you have maintenance and don't want to post it here, please open a support ticket.

          Possibly, you could use /Wix/Product/Feature[@Id="Complete"] as the target, and you would insert <ComponentGroupRef Id="Dll" /> as the Last Child, but it depends how you are using Features.

          Ulrich

          Comment


          • #6
            Ok, I got your file and had a look. I made a few modifications, which I'll try to explain below. Please download the zip file from my server, and decompress it somewhere. Then open the project file "scanning-edited.msifact". There are two other versions, where I removed the bootstrapper and the ODBC installer. I tested without these features. Now back to your project:

            First, please note that I removed the files WinSCPnet.dll and WinSCPnet.tlb from your files. As we are harvesting them, they will be included with the aid of the WiX fragment. Leaving them in the list of files will cause a conflict, and the compiler will complain about duplicates etc.

            Now, check Build Settings > Variables. You will see that I created a variable named "winscp", and defined it as the location where the source files can be found.

            Now please check the Fragments tab of the Build Settings. Here you will two custom entries, one for each fragment.

            For creating the WiX fragments, I use the batch file I placed in the "Build Files" folder. There, you will see that I use
            -dr winscp_0001 - setting the folder where the file is deployed;
            -var var.winscp - setting the source location of the file, so it can be found during the build.

            Finally, please see the Options tab of the Build Settings. In the compiler options, you see that I added
            -dwinscp=$(var.winscp) and -sw1118

            The -dwinscp part is a cyclic definition for the "winscp" variable, without it, the compilation will fail. The definition of winscp is the contents of winscp. It looks kind of dumb, but try to remove it, and the compiler will complain.

            The -sw1118 is for the suppression of the warning The variable 'winscp' with value 'D:\eSupport\PPro\bin\winscp' was previously declared with value 'D:\eSupport\PPro\bin\winscp'.

            Now please try to build the modified package. It should work. I installed the plain MSI package on Windows 8.1 x64, and there were no errors shown during or after the setup. As you can see in the screenshot below, the icon was installed, the two files I removed from the project are still there, and there are a few entries in the registry about the component, so I think that there is a chance that it worked correctly.


            Please let me know how this went.

            Ulrich

            Comment


            • #7
              Ulrich, I just tested it out. It works! Thank you so much for taking the time to figure this out. I would not have been able to get it to work without your help.

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎