简体   繁体   中英

Using a VB6 Class in C#

是否可以在C#中使用VB6类?

I think you should just be able to add the library that contains your VB6 type as a reference in your C# project. Visual Studio will create an Interop Assembly on the fly, and you'll get access to all of the types in the VB6 library via Runtime Callable Wrappers .

The tool that creates the Interop Assembly is TLBIMP.EXE , and you can run this yourself if you want more control over the process, eg. if you want to create a Primary Interop Assembly that might be shared by multiple managed components.

You can use a compiled VB6 dll in a C# program by using COM Interop.

https://stackoverflow.com/questions/tagged/interop

As @Wayne states in his post (+1) it is absolutely possible.

I would go for a rewrite of your VB6 class:
If you have the VB6 source and the funding, I would recommend you to rewrite the class in C#.
Although VB6 may live forever :
Current support Statement for Visual Basic 6.0

当然,你只需要把它变成一个COM对象。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM