Imports System.Runtime.InteropServices
<System.Runtime.InteropServices.ProgId("HC65Reports_NET.HC65Reports"), _
ClassInterface(ClassInterfaceType.None)> _
Public Class cHC65Reports
Implements _IReports
The imports and the class interface go together. This is what gives VB6 the references in the object explorer. Without it you will only have a high level class stub in your VB6 object browser.
You use the REGASM to register the dll and create the typelib file for visual basic to reference. Once you have created the tlb file you can reference it in visual basic.
All the files created in the bin directory need to reside in the same directory as your visual basic exe. I compiled my VB6 program exe and copied it to the .net bin directory to test.
Alternatively, the dll could be assign a strong name key (snk) and registered in the GAC. However, are trying to avoid GAC entries. We would like to use copy deployment if possible.
When VB6 in debug mode, it will get a runtime error stating that it cannot find a file or assembly name. I am guessing that this is because VB6 is running the code from a temporary directory and not the actual directory of your project.
You can run your visual studio .net in debug mode using your vb6 executable as the startup program.
See
http://radio.weblogs.com/0124037/stories/2003/08/18/debuggingComInterop.htmlI would like to be able to tell VB to use the .net bin folder when running in debug mode.
If you try to reference the .net dll file instead of the .tlb file you will get an error when trying to reference it and you will get an "Two different copies of MSCOREE.DLL have been loaded" when you try to run the VB6 application in debug mode. Restart VB6 to clear the error.