'Custom' modifier is not valid on events declared in interfaces
A custom event cannot be declared in an interface because a custom event must provide an implementation of its AddHandler, RemoverHandler, and RaiseEvent methods.
The Custom keyword can be used in a derived class that implements the event.
Error ID: BC31121
To correct this error
- Remove the Custom keyword from the event declaration in the interface.
Example
This example shows how to implement an event declared in an interface as a custom event.
Interface TestInterface
Delegate Sub TestDelegate(ByVal sender As Object, ByVal i As Integer)
Event Test As TestDelegate
End Interface
Class TestClass
Implements TestInterface
Public Custom Event Test As TestInterface.TestDelegate _
Implements TestInterface.Test
AddHandler(ByVal value As TestInterface.TestDelegate)
' Code for adding an event handler goes here.
End AddHandler
RemoveHandler(ByVal value As TestInterface.TestDelegate)
' Code for removing an event handler goes here.
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal i As Integer)
' Code for raising an event goes here.
End RaiseEvent
End Event
End Class
See Also
Reference
Class Statement (Visual Basic)
Interface Statement (Visual Basic)