问题描述
我在 c# 中创建了一个类,并使 com 可见属性为 true.但是,我在 Visual Basic 6.0 中看不到它的属性.可能是什么问题?请帮帮我
I have created a class in c# and made the com visible property is true. But, i could not see the its properties at visual basic 6.0. what could be a problem? please help me
推荐答案
定义一个也是 ComVisible 的公共接口,并让你的类实现它.
Define a public interface that is also ComVisible, and have your class implement that.
然后使用 tlbexp.exe 从您的 C# 程序集生成类型库:
Then use tlbexp.exe to generate a type libary from your C# assembly:
tlbexp ComServer.dll /out:ComServer.tlb
您需要从 VB6 添加对类型库的引用,而不是程序集.那么VB6如何知道你的程序集实际在哪里呢?Regasm 是怎么回事.它相当于 .net 程序集的 regsvr32.
You need to add a reference to the type library from VB6, not the assembly. How does VB6 know where your assembly actually is then? Regasm is how. It is the equivalent of regsvr32 for .net assemblies.
regasm ComServer.dll
这篇关于c# 类的属性在 Visual Basic 6.0 中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!