How do I call a visual basic 6.0 method in c#?
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?
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.)
Compile your VB6 DLL as activex dll
Register it using -> regsvr32 "Full Name And Path of newly compiled vb6 dll".(use Run Dialog or Command Prompt to register)
In .net Add refrence - select com tab and search this newly registered dll
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
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.
It's possible if and only if the VB6 code is compiled as a COM server.
.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.
精彩评论