Call vb6 dll from c #

I am trying to call a vb6 dll from a C application without using the registry. I want to use the path to the dll when using it. I can not create an object of class dll vb. Please help! The code I have written so far is as follows:

Assembly assem = Assembly.LoadFile("dll path"); Type classType = assem.GetType("classname"); MethodInfo method = classType.GetMethod("show"); //My methos is called show method.Invoke(null,null); // I have to invoke the method using class object, which I am unable to create 
+6
source share
3 answers

VB6 DLL is a COM library. Usually you register the DLL (in the registry) and then add the link to the VB6 DLL from your .NET project.

This MSDN article provides a step-by-step guide on using a COM application without using a COM application.

+6
source

Your VB6 library, as MarkJ mentioned, is a COM-Dll, and they usually need to be registered with regsvr32 before you can use them.

After registration, you can add a link to it in the same way as with .NET dll, that is, right-click the "Links" link in the project, click "Add Link", then select the "COM" tab in the window and see your COM Name Dll.

Then you can use it as a .NET link.
The following is an example of using the COM link to Microsoft Excel.
A practical guide. Using COM Interop to Create an Excel Spreadsheet

If you need a late binding, then your dll should still be registered, but you donโ€™t manually add the link, you use Activator.CreateInstance () to get an instance of your COM object.
Call COM component from C # using late binding

+2
source

Assuming the show method is in the export table in the dll, try using DllImportAttribute to call the show method.

+1
source

Source: https://habr.com/ru/post/908302/


All Articles