[JDEV] JabberCOM in C#
Nathan Phelps
nphelps at solarc.com
Fri Feb 16 10:19:09 CST 2001
Does anyone have any experience using JabberCOM from Microsft's new C#
environment? I can't figure out how to do events. According to the C#
documentation you use a delegate. All the examples use the ever popular
button like so:
Button button = new Button();
button.Click += new EventHandler(this.myButtonClickHandler);
Then, in your class, you define a method called myButtonClickHandler which
handles the event like so:
public void myButtonClickHandler(object sender, EventArgs e){
//handle this event here.
}
This does indeed work for buttons and other events I've tested. However, I
can't seem to get the events in JabberCOM to work.
JabberSession session = new JabberSession();
session.OnConnect += new EventHandler(this.myOnConnectHandler);
public void myOnConnectHandler(object sender, EventArgs e){
//handle this event here.
}
It throws the following exception:
U:\Personal\Development\Projects\CSharp\Jabber\Class1.cs(14): Cannot
implicitly convert type 'System.EventHandler' to
'JabberCOM.IJabberSessionEvents_OnConnectEventHandler'
I am further mystified by the fact that the C# IDE shows all these extra
methods that I don't see from Visual Basic. For each event it includes an
add[EventNameHere]Handler and a remove[EventNameHere]Handler. Each takes
that particular type of event as its argument. I tried using these and
passing in an IJabberSessionEvents_OnConnectEventHandler, but as you might
imagine, that didn't work either.
Any ideas?
Thanks,
Nathan
More information about the JDev
mailing list