© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
28 replies
Asher

❔ Using Event Handler null exception

Definition (in
EventHandlerClass
EventHandlerClass
)
public EventHandler<ActionMessage> OnAction;
public EventHandler<ActionMessage> OnAction;


Usage:
EventHandlerClass.OnAction += ActionUsage;
EventHandlerClass.OnAction += ActionUsage;


this gives me a null exception on the Usage line, is there something I'm doing wrong here? (this is before invoking, or doing anything else, however, I do think it has something to do with
OnAction
OnAction
not being initialized, but I couldn't find any examples where it is initialized.

The handler signature and event args match.
Is this correct usage? or do I have something else wrong with my code?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Null exception
C#CC# / help
3y ago
Help: Using an Event handler. (NAudio)
C#CC# / help
3y ago
Null reference exception
C#CC# / help
13mo ago
AspNetCore Null Exception
C#CC# / help
2y ago