I've been trying to solve this issue for a long time, and nothing seems to work.
I have a COM DLL written in vb6. I add a reference to this DLL in .net, with the 'isolated' and 'copy local' properties set to true on the reference. Apparently this is supposed to enable reg-free com.
But it doesn't work. If I try on another computer, or unregister the DLL with regsvr32, trying to access the DLL throws an exception (essentially saying the desired com class does not exist). The DLL and manifest files are in the same folder as the EXE, but it apparently just totally ignores them.
What am I doing wrong? I've read a ton of scattered articles about this but none of them give me a working solution. I've tinkered with visual studio to no avail. I've tinkered a small amount with make-my-manifest, but it didn't work (even on a test project).
I was creating and using the com class on a non-ui thread. Apparently Reg-Free com on vb6 DLLs doesn't work in that situation. This test code shows it:
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 the DLL registered normally, both tests succeed. If I use reg-free com, the threaded test fails even though the normal test still succeeds. Looks like this is going to be a huge pain to work-around.
I'm pretty sure that when you reference COM components in this way, the COM component import happens every time you build. That means that the COM component must be registered the traditional way on every machine the project will be built on.
Here's a link that describes using registration free com interop. If you've already done this please post your manifest file. You might have a typo your missing.
Edit
Just a thought might be simpler to just register the dll the first time the app runs on a new machine. Registration free com interopt is only available on Windows XP and newer so if your targeting any dinosaurs out there it won't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With