VB.NET 2005, RemoveHandler

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.
 
A

Armin Zingler

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
 
S

Sid Price

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.
 
R

rowe_newsgroups

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/
 
J

J.B. Moreno

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top