Define events in COM built in .NET
Hi everyone.
I built in .NET a 'class library' project , which then I
compiled with "Register for COM interop".
I also added some events.
I use this component in VB6, but I can't hook up to the
events.
Can someone please help?
In the .NET component's code, I tried to define events in
2 different ways:
1."
public delegate void ClickedEventHandler(string val);
public event ClickedEventHandler Clicked;
and then...
if(Clicked!=null) Clicked(txt.value);
"
2. [InterfaceTypeAttribute
(ComInterfaceType.InterfaceIsDual)]
public interface IMonitorEvent
{
void HandleMonitorEvent(bool IsEmergency);
}
Then, in order to hook up to those events in VB6:
1. I added a refernce in VB6 to the component.
2. I created instance
"
Dim MyObj As ContainerForIE.Form1
Set MyObj = CreateObject("ContainerForIE.Form1")
MyObj.Show
"
3. I tried to use
"Public WithEvents MyObj As ContainerForIE.Form1"
But it raises an error "Object does not source
automation events"
Can anyone help please?
|