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

杀马特。学长 韩版系。学妹 提交于 2019-12-29 08:46:10

问题


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?


回答1:


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.)




回答2:


  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




回答3:


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.




回答4:


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




回答5:


.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.



来源:https://stackoverflow.com/questions/4310681/how-do-i-call-a-visual-basic-6-0-method-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!