Answered by:
Registering for events in VB.NET 2008

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- Proposed as answer by Gibbloggen aka John Leone Wednesday, June 25, 2008 11:55 PM
- Marked as answer by Riquel_DongModerator Monday, June 30, 2008 2:41 AM
Tuesday, June 24, 2008 12:08 AMModerator
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- Proposed as answer by Gibbloggen aka John Leone Wednesday, June 25, 2008 11:55 PM
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- Proposed as answer by Gibbloggen aka John Leone Wednesday, June 25, 2008 11:55 PM
- Marked as answer by Riquel_DongModerator Monday, June 30, 2008 2:41 AM
Tuesday, June 24, 2008 12:08 AMModerator -
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 SheltonWednesday, June 25, 2008 8:05 PM