Please can some1 tell me as to what is wrong with my code?
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);
}
}
}
I call this from my VBA code
Private WithEvents moCom As ComMsg.M
Public Function Run() As Boolean
Set moCom = New ComMsg.M
it fails at
New ComMsg.Message
and i get an error message
"Object or class does not support the set of events"
Please help to resolve this issue. Thanks