Search code examples
c#vb6com-interopregasm

In VB6 application, CreateObject for a c# dll fails with "ActiveX component can't create object" in IDE only


I have C# assembly that I need to use in VB6. I've had this working on previous machines/OS, but on my current Windows 10 machine I can't get it to work when debugging in VB6/VS6 IDE. Whenever, I hit the line:

Set interop = CreateObject("BTR.Core.Interop.Activator")

I receive an 'ActiveX component can't create object.' error.

If I run the compiled VB6 application, everything works. So it must be a permission problem somewhere regarding the VB6/VS6 IDE.

I've found other posts mentioning to make sure to use 32bit version of regasm and I've tried both regasm and C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe to no avail.

Since it works when I run the compiled VB6 application (and since both the application and VB6 application worked on previous machines), I think that proves that all the settings for exposing my C# dll to COM are correct, but I'm happy to dig for more details on that if anyone thinks it is pertinent.

Only suspicious thing I saw was that this post (Late binding run-time error in VB6 when creating an object from a .NET assembly) talks about what should be in the registry after running regasm. All my settings are in the WOW6432NODE key at

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{2942ED53-BBC4-311D-9840-1FE610885592}.

So not sure if there is some sort of 32/64 bit conflict or what. Any suggestions are appreciated.


Solution

  • Well, I found a solution. I'm not sure if it was the right one. But I found other posts similar to this problem that talked about running regasm with the /tlb parameter to create a type library and then reference that in VB6. I didn't want to have that reference when I deployed the application to another machine so I kind of ignored the advice.

    Finally, I decided to try using that param and referencing the type library and then VB6 IDE debugging worked.

    But the weird part (and good for me) is, I then removed the reference and the VB6 IDE continued to work. So somehow, adding the reference in VB6 did 'something' to make it work when running in the IDE even after I had removed the reference.

    Hope this helps anyone else that might be stuck maintaining VB6 applications on new Windows operating systems.