Calling vb6 dlls from c#

前端 未结 3 1400
挽巷
挽巷 2021-01-18 04:41

I have been trying to call a vb6 dll from a C sharp application, without using the registry. I want to use the path of the dll while using it. I am unable to create an objec

相关标签:
3条回答
  • 2021-01-18 05:20

    Your VB6 dll as MarkJ mentions is a COM Dll, and they usually need to be registered using regsvr32 before you can use them.

    Once it's registered you can add a reference to it the same as you would with a .NET dll, i.e. right click on References in the project, click Add Reference, then select the COM tab on the window and look for your COM Dll name.

    Then you should be able to use it like a .NET reference.
    Here is an example of how to use a COM reference to Microsoft Excel.
    How to: Use COM Interop to Create an Excel Spreadsheet

    If you specifically want late binding, then your dll still needs to be registered but you don't manually add a reference, you use Activator.CreateInstance() to get an instance of your COM object.
    Calling COM component from C# using late binding

    0 讨论(0)
  • 2021-01-18 05:22

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

    This MSDN article gives a walkthrough of using registry-free COM from a .Net app.

    0 讨论(0)
  • 2021-01-18 05:34

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

    0 讨论(0)
提交回复
热议问题