DotRas.RasConnectionWatcher exception

Mar 22, 2010 at 1:20 PM

I'm running the latest version of the code (56295) to do connections using Mobile Phones as USB modems.

I'm user a watcher to handle disconnection events

 

After several attempts, The following Exception appears and I don't know where to handle it:

 

The specified port is not open.

at DotRas.ThrowHekper.ThrowRasException(Int32 error Code)

at DotRas.RasHelper.GetActiveConnections()

at DotRas.RasConenction.GetActiveConnections()

at DotRas.RasConenctionWatcher.ConnectionStateChanged(Object obj, Boolean timedOut)

at System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_COntext(Objectstate, Boolean timedOut)

 

 

and then the follow exception appears:

 

The connection was terminated

at DotRas.ThrowHekper.ThrowRasException(Int32 error Code)

at DotRas.RasHelper.GetActiveConnections()

at DotRas.RasConenction.GetActiveConnections()

at DotRas.RasConenctionWatcher.ConnectionStateChanged(Object obj, Boolean timedOut)

at System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_COntext(Objectstate, Boolean timedOut)

 

 

Do you know what might be the issue?

Coordinator
Mar 22, 2010 at 3:01 PM

What operating system and DotRas build (WIN2k, WINXP, etc) are you using?

I've never seen that error returned from the RasEnumConnections API, ever. You won't be able to handle the exception, that watcher class receives events on a separate thread which then calls the GetActiveConnections method. I can only imagine it's a hardware issue returning an error from the mobile phone, which is returned back to the RasEnumConnections API. Have you tried to replicate the problem using a normal modem?

Mar 22, 2010 at 4:29 PM

I'm using DotRas build for WINXP service Pack 2.

I haven't try to replicate it with a normal modem, and I won't be able to do it because I haven't got any.

 

Do you think I might have a way to solve it?

 

 

 

 

Coordinator
Mar 22, 2010 at 4:43 PM

Unless the modem driver stops reporting that the port is not open, no.

I'll have to make some modifications to the component later this evening once I'm done with work to trap the unhandled exceptions that are being thrown. Check back with me later, until then if you have the code available you can wrap the ConnectionStateChanged method in RasConnectionWatcher in a try/catch block.

The official fix should be done this evening to prevent the unhandled exceptions. Thanks for reporting the problem!

Mar 22, 2010 at 4:56 PM

I should say thanks to you for fix it!

Coordinator
Mar 22, 2010 at 6:40 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Mar 23, 2010 at 5:19 AM

Alright, I've fixed the issue with the component. Instead of throwing the exception, it will now be caught and forwarded to the Error event on the class. This should prevent the component from throwing any exceptions that cannot be handled within your application.

I think I might review the other multi-threaded components and ensure this same practice applies to those as well.