Re: Event question

Tech-Archive recommends: Fix windows errors by optimizing your registry



Rainer Queck wrote:
Hi,

in a base class I have declared the following event handler:

public abstract class MyBaseClass : :MarshalByRefObject
{
....
  public event EventHandler OnMsgSent;
...
}


In a derived class I try to call this event in the following way:

public override void MsgSent()
{
    if(OnMsgSent != null)
    {
        GbMessageEventArgs e = new GbMessageEventArgs(this);
        e.InfoString = "Message was successfully sent!";
        OnMsgSent(this,e);
    }
}

but when I trie to compile this, I get the following error message:
"The event ,<my namespace>.<base class>.OnMsgSent' can only appear on the
left hand side of += ...."


[I have doubt that this error appears where you register the event, can you show us how you register the event too].


What is it I am doing wrong?

Thanks for hints.
Rainer



.