views:

93

answers:

2

I am using a free .net telnet component (De.Mud.Telnet), which has several asynchronous methods you can call, and the component fires events when things happen. My problem is that the component is throwing an exception and I don't know how to catch it. There's no exception event, and the exception doesn't get thrown by my method call. I'm using this component from a service, and I don't know how to trap the exception.

+1  A: 

Check the latter part of this page, it is part of a good .NET threading guide that I refer to often for threading help.

JYelton
It's very useful indeed!
Skurmedel
Unfortunately I didn't write the component, so can't add the thread handling in there.
Jeremy
sorry that should have read, "can't handle the exception handling in the asynchronous method."
Jeremy
I understand; then that makes me as interested as you to know the solution!
JYelton
+1  A: 

Source code appears to be available here. Not sure of course, but it certainly matches your problem description. Whomever wrote this code was quite clueless about how exceptions work. The callbacks are the problem, when something goes wrong they throw an ApplicationException. Those exceptions are uncatchable, the callbacks are made on a threadpool thread.

This might have worked somewhat back in the .NET 1.x days, it would simply stop working properly instead of aborting your program. At least you're ahead, you now know it isn't working properly. Given that the code does very little and that the way it works is basically unfixable, I'd have to strongly recommend you just forget about using this.

Check out nsoftware.com for a company that sells a real library.

Hans Passant
Thanks. I found this code and made the appropriate changes.
Jeremy