RegAsm for Class Library Used in VB6 Application
- by michael.lukatchik
To be short and to the point, I've built a C# class library that is both COM-Visible and Registered for COM Interop. I've compiled the library, which resulted in the generation of .dll and .tlb files.
I have another machine that's running a VB6 application. So, I copied the .dll and .tlb files over to C:/Windows/system32 folder on the machine. I then registered those files using the following:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm C:\Windows\system32\TestClass.dll /tlb:TestClass.tlb
After the files were registered successfully, I added a project reference to the Test.tlb file from inside my VB6 app, then I tried to invoke a method in my new referenced class like so:
Dim myObject As TestNamespace.TestClass
Set myObject = New TestNamespace.TestClass
MsgBox (myObject.TestMethod())
It doesn't work, and I receive a -2147024894 Automation Error.
I've read that I shouldn't install the dll into a private folder like system32. I should either be registering in the GAC or I should be registering in another location using the "/codebase" option:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm C:\TestClass.dll /tlb:TestClass.tlb /codebase
Is there any reason I shouldn't be using system32? Past devs that have worked on this project have placed assembly files used by this VB6 project into system32 and there haven't seemed to be any issues.
When I register my dll in the system32 location, I get the Automation Error. When I register my dll in another location (i.e. C:/), the method call into my class library from VB6 works as expected. What gives?
I should mention that we will NOT be using the GAC to register any DLL's. That's just the way it is.
Any help is appreciated.
Mike