I have ActiveX VB6 DLL (have no access to its sources), and want to call method 'GetUnitInfo'
I use to import it like:
[DllImport(@"C:\Users\R\Documents\lab.dll")]
public static extern long GetUnitInfo(String strRequest, String strInfo, String strName);
But I get an exception:
Unable to find an entry point named 'GetUnitInfo' in DLL
Also I have tryied to load it:
Assembly myAssembly ;
myAssembly = Assembly.LoadFile("C:\\Users\\R\\Documents\\lab.dll");
but getting an exception
The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
I have tryied to clean solution, to turn off manifest in project options, to create new manifest file, but it did not helped me...
Compile the VB Project into the DLL and then import a reference to it. You can create a solution that contains VB projects and C# projects. you just can't have C# and VB.NET class files in the same project.
In VB, you create a Dynamic Link Library (DDL) by selecting ActiveX DLL from the New Project dialog box. This tip highlights the various uses and benefits of using DLLs. A Dynamic Link Library (DDL) is a file that. contains compiled code.
Found solution, mb someone else will find useful, (this worked in my case):
Create .Net wrapper of VB6 ActiveX dll
1.1 Run CMD as Administrator
1.2 Move to .NET SDK folder - cd C:\Program Files\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\
(in my case).
1.3 Run - TlbImp.exe C:\path_to_old.dll /out: new.dll
Register ActiveX dll
2.1 Run CMD as Administrator
2.2 Run - regsvr32.exe C:\path_to_old.dll
I used to add "new.dll" reference before registering "old.dll", and was getting the following exception
Retrieving the COM class factory for component with CLSID {F2D4F4E5-EEA1-46FF-A83B-A270C92DAE4B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Cleaning solution, removing reference and following steps 2,3 - helped
You may also find useful this articles
C-Sharp-and-activex-dll
Error adding reference to dll: Solution tlbimp.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With