Related to: C#: Raising an inherited event
When trying to raise an event defined in an inherited class (implemented in C#), the compiler throws a BC31132 error which states:
'RaiseEvent' definition missing for event Event
The help article linked above says:
If an event is declared as Custom, it must supply a procedure for raising the event.
However, the Object Browser doesn't show that the event is implemented as Custom:
Why is VB.Net complaining about a custom event when I haven't defined it as such?
Example
Parent C# code that implements the base class to be inherited:
public class EventGenerator
{
public event EventHandler SomethingHappened;
public void SampleMethod()
{
// Event is invoked without issue.
SomethingHappened?.Invoke(this, new EventArgs());
}
}
Child VB.Net class that inherits the base class and attempts to call the event:
Public Class TestClientClass
Inherits EventGenerator
Public Sub TestRaiseInheritedEvent()
' BC31132
RaiseEvent SomethingHappened()
End Sub
End Class
Further reading
https://learn.microsoft.com/en-us/dotnet/standard/events/ https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/events/ http://jmcilhinney.blogspot.com/2009/11/defining-and-raising-custom-events.html