I am trying to create a DLL in VB.NET (2012) which I will then use in several existing VB6 applications.
I have already built the DLL but I cannot get VB6 to use it! I created a DLL registered for COM interop, run regasm and pretty much everything else I found on the net, and I ended up with "myClass.dll" and "myClass.tlb".
Going back to VB6 now, I added the tlb to the references (the dll cannot be added it seems). When I run my application, at the point where I try to create a new instance of my main dll class, I get a crash instead... "ActiveX component can't create object"
I remember that this is related to dll's that are not registered, but when I try to register the tlb with regsvr32 I get "myClass.tlb is not an executable file and no registration helper is registered for this file type." and when I try to register the dll I get "myClass.dll was loaded, but the DllRegisterServer entry point was not found. This file can not be registered.".
What am I missing? is it correct that I need both files (dll & tlb) and that I need to reference the tlb and register the dll?
I am coding the dll in VB.NET under windows 7 64bit and the executable is in VB6 winXP 32bit, but I made sure that I targeted "any CPU" in the dll compile properties, so this should not be a problem.
I am attaching the code for "myClass":
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "74d3a0f0-3f5b-4d48-9dc4-4df224043e1e"
Public Const InterfaceId As String = "ed7e662f-bd37-44f3-b9eb-11ab1f262358"
Public Const EventsId As String = "04c9bb8b-0db3-4578-adcb-51d461d28d99"
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
Public Sub hi()
Dim frm1 As Form1 = New Form1
I have read through these articles but none of them referred to the "entry point not found" issue. Are you sure that this is related to 32bit/64bit issues? Again, I have compiled for "all CPUs" and even tried 32bit only. Shouldn't this resolve the problem if it was bit-related?
I initially thought that you need to do the "regasm" in the development machine and then transfer the dll to the target machine and register with "regsvr32" there.
This is wrong! Instead, when you create a DLL in VB.NET then you need to register it directly in the target machine using "regasm.exe" (which is in the .NET redistributable) and NOT with "regsvr32.exe".