How do I call a visual basic 6.0 method in c#?

2019-01-28 01:45发布

I would like to call a method which is written in visual basic 6.0 from c# (visual studio 2008). Is it possible? How would I do it?

5条回答
劫难
2楼-- · 2019-01-28 02:25

.NET can use your VB6 DLL like any COM DLL.

Just click to "Add reference", then choose the "COM" Tab if your DLL is already registered, or just click the "Browse" Tab in order to select the file directly.

If COM compatible, Visual Studio will automaticly create a COM Interop Assembly that will act as a .NET wrapper to your VB6 DLL.

You will have to deploy your VB6 dll and the Interop assembly with your program.

查看更多
做自己的国王
3楼-- · 2019-01-28 02:32
  1. Compile your VB6 DLL as activex dll

  2. Register it using -> regsvr32 "Full Name And Path of newly compiled vb6 dll".(use Run Dialog or Command Prompt to register)

  3. In .net Add refrence - select com tab and search this newly registered dll

  4. Now you can use this dll.

Note:

Whenever you do any changes in vb6 code, you have to follow above steps again.

To unregister vb6 dll use regsvr32 "Name and path" /u

welcome to (dll) hell

查看更多
Anthone
4楼-- · 2019-01-28 02:38

Yes. It is possible. You call it just like you call a method which has been written in Visual Basic. You need a reference to the assembly and then you just call it with the right namespace.

查看更多
闹够了就滚
5楼-- · 2019-01-28 02:41

It's possible if and only if the VB6 code is compiled as a COM server.

查看更多
ら.Afraid
6楼-- · 2019-01-28 02:47

Easiest way to do it is to just compile the VB6 code as an ActiveX DLL. Then you can reference the DLL in your .net project. (Visual studio can reference ActiveX DLLs properly.)

查看更多
登录 后发表回答