Search code examples
uwpdesktop-bridge

Calling a COM Interop .Net assembly from Visual Basic 6.0


We have a project running on Visual Basic 6.0 we try to migrate within Desktop Bridge. Everything works fine, when we use DAC command prompt. The converted application, converted as is, is working fine on any test computer.

We even managed to add a COM Interop .NET assembly to be able to use UWP features (like toasts)

Everything works fine on any dev machine, but not on a test machine. Well, the loading of the COM Interop .Net Assembly from Visual basic seems not working.

The main difference from the test machine and dev machine :

  1. On the dev machine, Visual Studio 2017 is registering the dll as COM interop (with regasm, Under the Hood)
  2. On the test machine, we first making a .msi setup file (with Visual Studio 6 Installer, yes the OLD one interdev style IDE ;), then we apply the DAC command line to this new .msi

So, It appears we have to register, manually, this assembly on the target test machine, with regasm ... since Visual Studio 6 Installer doesn't know how to register an interop assembly (using regasm)

How can we deal with that kind of scenario ?

As details we have Something straightforward :

  • MyApplication.exe (vb6)
  • MyWrappers.dll (and .tlb) (.net C# assembly marked for COM Interop AND referencing UWP SDK to be able to launch notifications)

Once again, the "installation" doesn't crash. Only the call to the COM Interop assembly for launching a toast notification.

Actually this error seems obvious if DAC didn't package this assembly for COM interop, and it make sense.

Any idea ? :)

Sebastien


Solution

  • Yes, you will have to make the COM registration part of your package deployment.

    One way to do it is to add the COM registration to your existing installer (or chain the two installers) and then run the DAC on it again.

    Another option would be to "manually" add the COM registration to the DAC output that you already have (i.e. add to the registry.dat file).

    A third option would be to not use COM at all, but instead use plain Win32 interop for calling UWP APIs from your VB6 app.

    I have published a sample/blog post for doing the latter: https://blogs.windows.com/buildingapps/2017/02/01/adding-uwp-features-existing-pc-software/