locked
Registering for events in VB.NET 2008 RRS feed

  • Question

  • Hey, I have this code in C#, but I am curious of its VB.NET equivalent... I get the error that InnerDuplexChannel.Faulted is an event and I cannot call it directly, I have to use raiseevent... Really I just want to register for the event and have it call the respected function here so I can keep state... Any ideas??

    Thanks guys! (This is a simple WCF client/service application)

    proxy.Open();

    proxy.InnerDuplexChannel.Faulted +=
    new EventHandler(InnerDuplexChannel_Faulted);
    proxy.InnerDuplexChannel.Opened +=
    new EventHandler(InnerDuplexChannel_Opened);
    proxy.InnerDuplexChannel.Closed +=
    new EventHandler(InnerDuplexChannel_Closed);
    Monday, June 23, 2008 9:46 PM

Answers

  • I think you need to say AddressOf after the comma on each line (before the name of the method).

    HTH,

    Jonathan
    Program Manager - Visual Basic
    Tuesday, June 24, 2008 12:08 AM
    Moderator

All replies

  • Jimmy Lipham said:

    proxy.Open();

    proxy.InnerDuplexChannel.Faulted +=
    new EventHandler(InnerDuplexChannel_Faulted);
    proxy.InnerDuplexChannel.Opened +=
    new EventHandler(InnerDuplexChannel_Opened);
    proxy.InnerDuplexChannel.Closed +=
    new EventHandler(InnerDuplexChannel_Closed);



    proxy.Open()  
    AddHandler proxy.InnerDuplexChannel.Faulted, InnerDuplexChannel_Faulted  
    AddHandler proxy.InnerDuplexChannel.Opened, InnerDuplexChannel_Opened  
    ' more of the same 

    HTH
    Tom Shelton
    Monday, June 23, 2008 10:00 PM
  • I think you need to say AddressOf after the comma on each line (before the name of the method).

    HTH,

    Jonathan
    Program Manager - Visual Basic
    Tuesday, June 24, 2008 12:08 AM
    Moderator
  • yep, both of you were exactly right. Worked like a charm! Can't thank you guys enough.
    Tuesday, June 24, 2008 12:36 AM
  •  Johnathan,

    You are correct :)  I did it off the top of my head, and forgot the addressof  - sorry.

    Tom Shelton
    Wednesday, June 25, 2008 8:05 PM