Referencing .NET Assembly in VB6 won't work
- by dretzlaff17
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!