VB.NET 2005, RemoveHandler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sid Price

    VB.NET 2005, RemoveHandler

    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.


  • Armin Zingler

    #2
    Re: VB.NET 2005, RemoveHandler

    "Sid Price" <sid@nowhere.co mschrieb
    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

    Comment

    • Sid Price

      #3
      Re: VB.NET 2005, RemoveHandler

      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.

      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:uCsMc1nSJH A.6060@TK2MSFTN GP06.phx.gbl...
      "Sid Price" <sid@nowhere.co mschrieb
      >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

      Comment

      • rowe_newsgroups

        #4
        Re: VB.NET 2005, RemoveHandler

        On Nov 19, 3:12 pm, "Sid Price" <s...@nowhere.c omwrote:
        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.
        >
        "Armin Zingler" <az.nos...@free net.dewrote in message
        >
        news:uCsMc1nSJH A.6060@TK2MSFTN GP06.phx.gbl...
        >
        "Sid Price" <s...@nowhere.c omschrieb
        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
        Hard to say / explain if you don't provide the offending code...

        Thanks,

        Seth Rowe [MVP]

        Comment

        • J.B. Moreno

          #5
          Re: VB.NET 2005, RemoveHandler

          Sid Price <sid@nowhere.co mwrote:
          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.
          "Armin Zingler" <az.nospam@free net.dewrote in message
          news:uCsMc1nSJH A.6060@TK2MSFTN GP06.phx.gbl...
          "Sid Price" <sid@nowhere.co mschrieb
          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?
          --
          J.B. Moreno

          Comment

          Working...