请问有人能告诉我我的代码有什么问题吗?
C#:
namespace ComMsg
{
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IM
{
[DispId(1)]
event M.MHandler OnMSend;
}
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IMEvents
{
[DispId(2)]
void sendM(M.Process status, string msg);
}
[ComSourceInterfaces(typeof(IM), typeof(IMEvents))]
[ClassInterface(ClassInterfaceType.None)]
public class Message : IM
{
public enum Process { Error, Complete }
public delegate void MHandler(Process status, string msg);
public event MHandler OnMSend;
public void sendM(Process status, string msg)
{
if (OnMSend != null)
OnMSend(status, msg);
}
}
}
我从我的 VBA 代码中调用它
Private WithEvents moCom As ComMsg.M
Public Function Run() As Boolean
Set moCom = New ComMsg.M
它失败了
新的 ComMsg.Message
我收到一条错误消息
“对象或类不支持事件集”
请帮助解决此问题。谢谢