【发布时间】:2011-07-10 08:31:16
【问题描述】:
我知道我大约在 6 年前解决了同样的问题......但我不太记得诀窍是什么。
我有一个 .NET 类。它是 COM 可见的(但未注册 COM)。它作为调用 COM 注册类的结果返回。所以我的 VB6 代码以
结尾Dim instance as Variant
' call .NET exposed tlb to set instance with a COM visible class
Dim wrapper as New ComWrapper ' this is a .NET class COM exposed and registered
Set instance = wrapper.MyClassInstance ' MyClassInstance is an instance of COM visible, but not COM registered MyClass defined below
instance.DoIt 1
相关类是 MyClass
public class MyClass
{
public void DoIt(int id) { ... }
}
调用 instance.DoIt 1 引发异常“需要对象”。如果我没记错的话,它与整数 1 需要被装箱或拆箱或其他东西有关,VB6 不会自动为你做......但我不记得如何修复它。 .. 如果 DoIt 方法没有参数,一切正常...
有人知道如何解决这个问题吗?
谢谢。
【问题讨论】:
标签: .net vb6 interop com-interop