Avatar of Richard
Richard
Flag 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
.NET ProgrammingC#Visual Basic ClassicMicrosoft Visual Studio

Avatar of undefined
Last Comment
Richard

8/22/2022 - Mon
AndyAinscow

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

ASKER
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.
AndyAinscow

Check it.  I think COM compatibility is something different from the bit size it is compiled with.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Richard

ASKER
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.
R