Link to home
Create AccountLog in
Avatar of Richard
RichardFlag for United States of America

asked on

VB6 can't talk to C# DLL

Hi All,
I have a C# DLL which was written for me to interface with my VB6 program.  The DLL is COM-Visible and the Register for COM interop selected.  The DLL has 3 methods Initialization, Up and Dn.

I have a small VB6 test program which access the DLL.

I'm using VS 2017 (run as administrator) to build the DLL
I have Visual Studio (VB6) on the same machine - A Windows 10 PRO system.

In my VB program I have a reference to the DLL (actually the TLB).  Intellesense works fine - I can see all three methods.
My startup code is:
Public Sub Main()
    Dim AM as AudioManager
    Set AM = New AudioManager       ' <<<==== Error here
End Sub

Open in new window

When I run the program I get an error at the Set statement - Runtime 429 - "ActiveX component can't create object".
I've done quite a bit of research on the web about this, and most of the similar issues are when someone tries to move a project from a development environment.  In my case , I'm getting this on the development system.
I have tried:
Tlbexp AM.DLL /out:AM.tlb
Regasm /tlb:AM.tlb AM.DLL
Gacutil /i AM.DLL
So far nothing seems to work.  I have put the DLL and TLB into the System32, SYSWOW64 and my VB6 application folders (registering it in each after removing from the previous location) - doesn't help.
Anyone have any ideas?
Thanks in advance
Avatar of AndyAinscow
Flag of Switzerland image

A 32 bit component will not work with a 64 bit component.  Check that both are the same bit size (probably 32 bit).
Avatar of Richard


Hi Andy,
Thanks for responding.
Not sure what you mean.  The c# DLL was compiled with COM compatibility.  To my way of thinking, that should have resolved any issue with bit size.
Check it.  I think COM compatibility is something different from the bit size it is compiled with.
Avatar of AndyAinscow
Flag of Switzerland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Richard


Hi Andy,
You were right.  I found that the "Platform target" was set to "Any CPU".  I changed it to x86, recompiled and it worked.  it's funny how it's the little things that will get you!

Thanks for your quick help.