Referencing .NET Assembly in VB6 won't work

Posted by dretzlaff17 on Stack Overflow See other posts from Stack Overflow or by dretzlaff17
Published on 2010-06-08T18:30:38Z Indexed on 2010/06/15 0:22 UTC
Read the original article Hit count: 542

Filed under:
|
|

I wrote a .net assembly using c# to perform functions that will be used by both managed and unmanaged code. I have a VB6 project that now needs to use the assembly via COM.

I created my .net assembly, made sure that ComVisible is set to true and that it is registered for COM interop via project properties.

public class MyClass

    [ComVisible(true)]
    public string GetResponse()
    {
        return "Testing Response"
    }

}

I build the assembly and copied the file into a folder. TestInterop.dll

I then run a batch file to register the assembly tool to register the object for COM.

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
regasm "c:\Program Files\TestApp\TestInterop.dll" /tlb:TestInterop.tlb

I open a new VB6 application and reference TestInterop.dll

In VB6 I write the following code and it compiles.

Dim obj as TestInterop.MyClass
Set obj = new TestInterop.MyClass

Dim strTest as string

strTest = obj.GetRespose()

When I run the program it errors on the obj.GetResponse() line.

Run-time error' -2147024894 (80070002'):
Automation error
The system cannot find the file specified

Also, the intellesense does not work on obj. I had to type the GetResponse method. Is this normal?

Does anyone have any clue what could be wrong or what steps I missed. Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about com