【发布时间】:2015-06-24 14:06:09
【问题描述】:
您好,我有一个名为 CLSFW_SBSession 的 vb6 接口,其中包含一个事件:
Public Event DataTransfer(ByVal Data As Variant)
Public Property Get ActionID() As Long
End Property
...
我需要用一个 c# 互操作类来扩展它。我试过了:
[ComVisible(true)]
[Guid("ddb976bd-fe29-44d5-a163-e7780a4bb897")]
public class ClsSbSession : FWBO_LibSrv.CLSFW_SBSession
public event __CLSFW_SBSession_DataTransferEventHandler DataTransfer;
...
现在,如果我在 vb6 中声明一个这种类型的对象并实例化它,而不使用事件,它就可以工作:
Private session As FWBO_LibSrv.CLSFW_SBSession
Set session = new ClsSbSession()
但如果我使用:
Private WithEvents session As FWBO_LibSrv.CLSFW_SBSession
我尝试实例化它:
Set session = new ClsSbSession()
我收到一个错误:
对象或类不支持事件集
如何管理来自 c# 类的 vb6 的事件?谢谢
【问题讨论】: