2
votes

I have a c# Adapter Assembly around a non-signed third party assembly, so I can't sign my assembly either. My Adapter Assembly is to be used by a VB6 program to access functionality in the third party assembly, which isn't COM. However, while I can register the assembly using regasm, and generate a tlb file, and reference it in VB6, I get an ActiveX exception when I try to Set my Dimmed variable to a new instance of my Adapter.

I have the corresponding .Net frameworks installed, and can run my adapter assembly from the command line via another .Net executable on the machine where VB6 is installed.

Here is how I am setting up my COM, sans Third-Party reference..just in case this is the issue..

    [ComVisible(true)]
    [Guid("F728D70E-ED98-456C-B8C6-4EA5B0EF8A1A")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("SimpleComClass452.MySimpleComClass")]
    public class MySimpleComClass : _MySimpleComClass
    {

        public int Add(int num1, int num2)
        {
            return num1 + num2;
        }
    }
    [ComVisible(true)]
    [Guid("C729E6FF-C2F5-4C9B-8200-A135E15576A6")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface _MySimpleComClass
    {
        [DispId(1)]
        int Add(int num1, int num2);
    }

How can I get to the bottom of the issues with accessing my .NET COM aware Adapter assembly from VB6? I've looked at procmon but can't see anything. Is there any way to ascertain where the problems lie?

1
Do c# dll and vb6 code have the same bittness? E.g. 32-bit code cannot use 64-bit COM object - Renat
What is the error you are receiving in VB6? - StayOnTarget
AFAIK strong-naming has no effect on VB6 COM interop at all. At the least I do lots of COM interop (VB6 calling C#) and don't sign anything. - StayOnTarget
Can you post the VB6 code, and specifically point out which line is giving you what error? - user65839
IIRC, if you want to install your COM interop assembly into the GAC, then it needs to be strong named. But if you just regasm register it, you should be able to instantiate it. When you're running the IDE, you might need to place a copy of your assembly in the same folder as vb6.exe (typically C:\Program Files\Microsoft Visual Studio\VB98). - MarkL

1 Answers

2
votes

@Renat called it in the comments on the original post.

Recompiled in VS2019 as explicitly 32 bit and swapped to use the x86 regasm at C:\Windows\Microsoft.Net\Framework\regasm.exe on the target machine.

I'm using a 64 bit OS (windows 2012 r2) to run VB6 on the target machine, but it will still compile to an x86 assembly.

So I guess the lesson is x86 for VB6, but I reckon you all knew that anyway :S