You are probably trying to write this code in a class that is a descendant of a class that declares a ChatEvent event. This is not possible because events can only be considered as variables (including their invocation) in the class that declares them. This is because the event keyword actually tells the compiler that it needs to perform some behind-the-scenes conversions.
What's happening
Consider this expression:
Public Event MyEvent as EventHandler
Simple enough, right? However, this actually happens (you just don't see it)
Private compilerGeneratedName as EventHandler Public Event MyEvent as EventHandler AddHandler(ByVal value as EventHandler) compilerGeneratedName += value End AddHandler RemoveHandler(ByVal value as EventHandler) compilerGeneratedName -= value End RemoveHandler RaiseEvent(ByVal sender as Object, ByVal e as EventArgs) compilerGeneratedName.Invoke(sender, e) End RaiseEvent End Event
And when you trigger the event:
RaiseEvent MyEvent(Me, EventArgs.Emtpy)
It actually calls the code in a RaiseEvent block.
Edit
If events in VB.NET cannot be considered variables anywhere (they can be considered variables in a declaring class in C #, so your C # example compiles), then you have to explicitly implement the event yourself. For more information on how to do this, see Page
Adam robinson
source share