VB.NET 2005, RemoveHandler

  • Thread starter Thread starter Sid Price
  • Start date Start date
S

Sid Price

I have a compiler warning I do not understand how to fix. I am trying to
remove an event handler and get the following message:

Warning 1 The 'AddressOf' expression has no effect in this context because
the method argument to 'AddressOf' requires a relaxed conversion to the
delegate type of the event. Assign the 'AddressOf' expression to a variable,
and use the variable to add or remove the method as the handler.

There appears to be no problem with the signature of the method and it was
added using AddHandler. Any suggestions would be much appreciated,
Sid.
 
Sid Price said:
I have a compiler warning I do not understand how to fix. I am
trying to remove an event handler and get the following message:

Warning 1 The 'AddressOf' expression has no effect in this context
because the method argument to 'AddressOf' requires a relaxed
conversion to the delegate type of the event. Assign the 'AddressOf'
expression to a variable, and use the variable to add or remove the
method as the handler.

There appears to be no problem with the signature of the method and
it was added using AddHandler. Any suggestions would be much
appreciated,
Sid.

Can you show us the line and involved declarations?


Armin
 
Although I don't understand why it is necessary I have fixed the issue by
declaring a variable, assigning the address of my handler to it and using
the variable as the parameter for RemoveHandle.
Sid.
 
Although I don't understand why it is necessary I have fixed the issue by
declaring a variable, assigning the address of my handler to it and using
the variable as the parameter for RemoveHandle.
Sid.

Hard to say / explain if you don't provide the offending code...

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
Sid Price said:
Although I don't understand why it is necessary I have fixed the issue by
declaring a variable, assigning the address of my handler to it and using
the variable as the parameter for RemoveHandle.

Well that is what the error message said to do.
 
Back
Top