C
Cedric B
I have the following code in C#, and it works fine. After porting the code
to VB.NET, I get a precompile error in the IDE. Does anyone know why this
could be happening?
protected delegate void MulticastDelegate(object sender, EventArgs e);
virtual public void Subscribe(object tag, EventHandler _eventHandler, bool
loose)
{
//... other code above omitted
// create the delegate for this event handler
MulticastDelegate newDelegate=new MulticastDelegate(_eventHandler);
//...other code below omitted
}
VB.NET Translation:
Protected Delegate Sub MulticastDelegate(ByVal sender As Object, ByVal e As
EventArgs)
Public Overridable Overloads Sub Subscribe(ByVal tag As Object, ByVal
mEventHandler As EventHandler, ByVal loose As Boolean)
'the line below is giving the pre-compile error
Dim newDelegate As MulticastDelegate = New
MulticastDelegate(mEventHandler)
End Sub 'Subscribe
The precompile error is as follows:
'MulticastDelegate' is a delegate type. Delegate construction permits only
a single AddressOf expression as an argument list. Often an AddressOf
expression can be used instead of a delegate construction.
to VB.NET, I get a precompile error in the IDE. Does anyone know why this
could be happening?
protected delegate void MulticastDelegate(object sender, EventArgs e);
virtual public void Subscribe(object tag, EventHandler _eventHandler, bool
loose)
{
//... other code above omitted
// create the delegate for this event handler
MulticastDelegate newDelegate=new MulticastDelegate(_eventHandler);
//...other code below omitted
}
VB.NET Translation:
Protected Delegate Sub MulticastDelegate(ByVal sender As Object, ByVal e As
EventArgs)
Public Overridable Overloads Sub Subscribe(ByVal tag As Object, ByVal
mEventHandler As EventHandler, ByVal loose As Boolean)
'the line below is giving the pre-compile error
Dim newDelegate As MulticastDelegate = New
MulticastDelegate(mEventHandler)
End Sub 'Subscribe
The precompile error is as follows:
'MulticastDelegate' is a delegate type. Delegate construction permits only
a single AddressOf expression as an argument list. Often an AddressOf
expression can be used instead of a delegate construction.