简体   繁体   English

在C#中使用VB6类

[英]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. 我认为您应该能够在C#项目中添加包含VB6类型的库作为参考。 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 . Visual Studio将动态创建一个Interop程序集,您可以通过Runtime Callable Wrappers访问VB6库中的所有类型。

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. 创建Interop程序集的工具是TLBIMP.EXE ,如果您想要更多地控制该过程,可以自己运行它,例如。 if you want to create a Primary Interop Assembly that might be shared by multiple managed components. 如果要创建可能由多个托管组件共享的主Interop程序集

You can use a compiled VB6 dll in a C# program by using COM Interop. 您可以使用COM Interop在C#程序中使用已编译的VB6 dll。

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

As @Wayne states in his post (+1) it is absolutely possible. 正如@Wayne在他的帖子(+1)中所述,这绝对是可能的。

I would go for a rewrite of your VB6 class: 我会去重写你的VB6类:
If you have the VB6 source and the funding, I would recommend you to rewrite the class in C#. 如果您有VB6源代码和资金,我建议您用C#重写该类。
Although VB6 may live forever : 虽然VB6可能永远存在
Current support Statement for Visual Basic 6.0 Visual Basic 6.0的当前支持声明

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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