Results 1 to 3 of 3

Thread: Very hard time with Events and Null

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Location
    Manchester, CT
    Posts
    317

    Angry 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:
    1. public delegate void ErrorOccuredEventHandler(object sender, clsCollections.ErrorOBject e);
    2.  
    3.     public class clsDBConnection
    4.     {
    5.         public event ErrorOccuredEventHandler ErrorOccured;
    6.         protected virtual void OnErrorOccured(clsCollections.ErrorOBject e)
    7.         {
    8.             if (this.ErrorOccured != null)
    9.             {
    10.                 this.ErrorOccured(this, e);
    11.             }
    12.         }
    13.  
    14.         private void ProcessError(string Reason, string ErrorMessage)
    15.         {
    16.             clsCollections.ErrorOBject NewLogMessage = new clsCollections.ErrorOBject();
    17.             NewLogMessage.ErrorCause = Reason;
    18.             NewLogMessage.ErrorMessage = ErrorMessage;
    19.             this.OnErrorOccured(NewLogMessage);
    20.         }

    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!
    "I dont even see the code anymore... I just see Blonde, Brunette, Redhead..."

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Location
    Manchester, CT
    Posts
    317

    Resolved [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!
    "I dont even see the code anymore... I just see Blonde, Brunette, Redhead..."

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width