winapiwindows-xpras

Windows XPe RAS error 756 "connection is being dialled"


I'm working with an embedded system which has a RAS entry already set up, using the API function RasDial from rasapi32.dll.

All works well except if something goes wrong after RasDial and before RasHangUp. In this case any further attempt to dial is met with error 756 "connection is being dialled", whether the dial attempt is done via the API or via the Windows rasdial command line utility.

rasdial connectionname /d doesn't help either.

The com port used for the modem is locked.

The only way to recover is to reboot.

Obviously under normal circumstances the solution is to make sure that RasDial is always followed by RasHangUp. But for cases where this doesn't happen, is there a way of aborting the dial attempt? For example, if the app calls RasDial and then crashes, how do I get out of that other than by rebooting?


Solution

  • Unfortunately, unless your application can properly terminate the connection that's in progress before exiting the RAS state machine becomes corrupted and must reboot to fix the problem. I've noticed that Windows 7 handles these sorts of scenarios better than XP and Vista did, but there are still occasions when I've had to reboot.

    I've managed to prevent most of these sorts of problems with the DotRas API as long as they're occuring in the event handlers of the RasDialer, but if the application crashes from another thread and not from the background thread which raises the RasDialer events, there's nothing I can do about that.

    For asynchronous dialing using the DotRas 1.2 SDK:

    using DotRas;
    
    RasDialer dialer = new RasDialer();
    dialer.EntryName = "My Connection";
    dialer.Credentials = new NetworkCredential("My", "User");
    dialer.DialAsync();
    

    From this point you can call dialer.DialAsyncCancel() if you want to cancel the connection attempt that's in progress.

    For synchronous dialing using the DotRas 1.2 SDK is very similar to asynchronous dialing other than replacing the DialAsync call with simply dialer.Dial().

    Here's a link to the API I was talking about: http://www.codeplex.com/DotRas

    Hope that helps!