Events can only be called from a class that declares them.
Due to the class definition (even in a derived class), you can only register and unregister with event. Inside the class, the compiler only allows raising an event. This is C #'s behavioral behavior (which actually changes a bit in C # 4 - Chris Burroughs describes the changes on his blog ).
What you want to do is provide a method RaiseLogEvent()in the base class that will allow the derived class to raise this event.
public abstract class Base
{
public delegate void logEvent(String message, int level);
public event logEvent log;
protected void RaiseLogEvent( string msg, int level )
{
logEvent evt = log;
if( evt != null )
{
evt( msg, level );
}
}
}
EventHandler<>, , .