I have created VB6 Project of ActiveX dll type added two function
Public Function Name(aName As String)
MsgBox ("Your Name is " & aName)
End Function
Public Function TestName(aName As String) As String
TestName = " Hello " & aName
End Function
Created DLL from same Project.
Then created Wrapper using below command .
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools>TlbImp.exe C:\Test\TestActiveX\Project1.dll /out: C:\Test\TestActiveX\out\Project1.dll
If i am performing only above operation then i am not getting Project1.dll under COM section but then i am registering dll using below code
C:\WINDOWS\system32>regsvr32 C:\Test\TestActiveX\Project1.dll
then only i am getting dll under COM section inside VisuaL studio Add Reference Dialog
i tried adding reference from C:\Test\TestActiveX\out\Project1.dll folder also but every time i am getting runtime error as below.
System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {ID} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'
public string ReturnFromCOM()
{
TestClass testClass = new TestClass();
return testClass.TestName(" Hello ");
}
i am not able to get it done, don't know what is missing in this steps. My Windows OS : 64 bit Windows 10 Framework 4.6.1 as well as 4.8.1 but created console application with Framework 4.6.1
i tried even changing project target to x64/x86/anyCPU but it's not working at all.
Check if your VB6 TestClass instancing is set to "MultiUse"
Also try referencing your VB6 dll from another VB6 project and try the same code (translated to VB6) as from C# function ReturnFromCOM.
User contributions licensed under CC BY-SA 3.0