How to use Reg-Free COM to link vb6 dll in .net project?

I tried to solve this problem for a long time and nothing works.

I have a COM library written in vb6. I am adding a link to this DLL in .net, with the attributes 'isolated' and 'copy local' set to true. Apparently this should allow reg-free com.

But that will not work. If I try on another computer or unregister the DLL using regsvr32, trying to access the DLL will throw an exception (in fact, the desired com class does not exist). The DLL and manifest files are located in the same folder as the EXE, but seem to completely ignore them.

What am I doing wrong? I read a ton of scattered articles about this, but not one of them gave me a working solution. I fiddled with the visual studio to no avail. I spent a small amount on make-my-manifest, but this did not work (even in the test project).

+4
source share
4 answers

I created and used the com class in a thread other than ui. Apparently, Reg-Free com on vb6 DLL does not work in this situation. This test code shows this:

Private Sub RunTest() Handles Button1.Click Try Dim x As New RegTestProject.RegTestCall MsgBox(x.RegTestFunction()) Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Sub RunThreadedTest() Handles Button2.Click 'fails if reg-free COM is used' Dim t As New Threading.Thread(AddressOf RunTest) t.Start() End Sub 

When I run this with a DLL registered normally, both tests succeed. If I use reg-free com, the threaded test will fail even if the normal test still succeeds. It looks like it will be a huge pain for work.

+4
source

I am sure that when you reference COM components this way, the import of COM components happens every time you create. This means that the COM component must be registered in the traditional way on each machine on which the project will be built.

+3
source

Here is a link that describes the use of free registration in com mode. If you have already done this, write a manifest file. Perhaps you have a typo that you lost.

Edit

Just a thought, it might be easier to just register the dll when you first run the application on a new machine. Registration free com interopt is available only in Windows XP and newer, so if your targeting any dinosaurs will not work there.

+2
source

Here is an excerpt from the Troubleshooting section in the MSDN article on reg-free COM. Sorry if you already saw this. The good news is that you are already part of this step. He suggests reproducing the problem in Windows Server 2003 (perhaps with Virtual PC ?), And then the event log should help.

First get ... your client working with a registered server; then unregister the server and make sure that your error message is what you expected; and finally ... craft and deploy manifest files. Therefore, troubleshooting efforts ... will be limited by the structure of your manifest files (and the proper manifest assembly attachment if you decide to do this).

When troubleshooting without registration COM problems, Viewing events on Windows Server 2003 is your friend ... look in the system event log for events from the COM server. I do not suggest you take a look at the Windows XP Event Log ... it will always contain a message ... that does not help identify the problem.

+2
source

All Articles