Very hard time with Events and Null
Hello All, I am new to C# (migrated from VB.net) and I am having a REAL hard time creating events in a DLL
Your help is really appreciated.
So I have a class in my DLL that has an event. (See below)
C# Code:
public delegate void ErrorOccuredEventHandler(object sender, clsCollections.ErrorOBject e);
public class clsDBConnection
{
public event ErrorOccuredEventHandler ErrorOccured;
protected virtual void OnErrorOccured(clsCollections.ErrorOBject e)
{
if (this.ErrorOccured != null)
{
this.ErrorOccured(this, e);
}
}
private void ProcessError(string Reason, string ErrorMessage)
{
clsCollections.ErrorOBject NewLogMessage = new clsCollections.ErrorOBject();
NewLogMessage.ErrorCause = Reason;
NewLogMessage.ErrorMessage = ErrorMessage;
this.OnErrorOccured(NewLogMessage);
}
Without fail "Error Occured" is ALWAYS null... I dont understand why this is happening, can SOMEONE please help, I am seriously frustrated and have probably spent a good 5 hrs trying to figure this out (and now feeling kinda stupid)
I hit up an article on MSDN about raising events that I found here on the forums, but I am still clearly missing something because even though I feel like i am following the directions it is still not working :(
Thanks in advance!
[Resolved] Re: Very hard time with Events and Null
I fixed the problem
I did not realize that my constructor was not firing due to a spelling error on my part.
Thanks for reading anyway!
Re: Very hard time with Events and Null
Please mark your thread Resolved if the issue is in fact resolved. You've simply put [Resolved] in the title of your second post, but that doesn't show in the forum thread listing. Use the Thread Tools menu.