This project is read-only.

Problem in dialing multiple times in an application...

Aug 25, 2009 at 10:19 AM

Dear Jeff,

Thanks for this excellent dot net library for RAS operations. I have recently tried using it in one of my projects. The integration was really easy.

I have run into a small problem is using dotRas in my application. My application uses DotRas to create a dialup internet connection, and upload files at regular intervals. After uploading the files, my application disconnects the internet connection.

For this I have an instance of RasDialer class in my file uploader class. When I launch the application, the initial dial up works file, and upload goes through without any problem. After which, my application disconnects dial up connection. On next scheduled upload time, when the uploader attempts to establish internet connection by dialing using RasDialer, it fails to connect.

When I stepped through RasDialer code, I found the problem. I am cut pasting the relevant code fragment from RasDialer.cs

My application calls Dial method

        public RasHandle Dial()
        {
            return this.Dial(null);
        }

The above method calls:

       public RasHandle Dial(NetworkCredential credentials)
        {
            return this.InternalDial(credentials, false);
        }

The above method calls:

        private RasHandle InternalDial(NetworkCredential credentials, bool asynchronous)
        {
            if (string.IsNullOrEmpty(this.EntryName) && string.IsNullOrEmpty(this.PhoneNumber))
            {
                ThrowHelper.ThrowInvalidOperationException(Resources.Exception_PhoneNumberOrEntryNameRequired);
            }

            lock (this._syncRoot)
            {
                // NOTE: The synchronization object MUST be locked prior to testing of the component is already busy.
                // WARNING! Ensure no exceptions are thrown because existing dial attempts are already in progress. Doing so leaves the
                // connection open and cannot be closed if the application is terminated.
                if (!this._dialing)                           <------------------------
                {                    
                    this._dialing = true;

Note that the member _dialing is being set to true. This variable is getting resetted to false only in asynchronous dialing scenario (in PostCompleted). It remains true for synchronous dialing. As a result, any subsequent call to Dial is not even attempted due to the if check indicated by arrow.

For now I have made following modification in InternalDial method in my local copy :

                     this._handle = RasHelper.Dial(this.PhoneBookPath, parameters, extensions, callback, this.EapOptions);

                    // ------- My Change Start ----

                   if (!asynchronous)
                    {
                        this._dialing = false;
                    }

                    // ------- My Change End ----

I haven't studied your code in detail, so I don't know if this change is valid or not, or if there a better way of fixing this issue.

Thanks,

 

Warm Regards,

- Vikram Lele

 

 

 

 

 

Aug 25, 2009 at 3:19 PM
Edited Aug 25, 2009 at 3:34 PM

Ahhhh, I see what you're getting at and it makes perfect sense. Good catch! I'll get a work item created for it and get it fixed for the 1.1 build.

Edit: I wanted to add a note that the code you changed was exactly where it needed to be. It should remain stable to use with the modification you made.

Aug 25, 2009 at 3:24 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 26, 2009 at 12:31 AM

Well it's all taken care of. There was another reusability issue that was fixed as well along with this one. The component should now be fine when being reused.

Thanks again for reporting the issue!

Aug 26, 2009 at 4:59 AM

Dear Jeff,

Thanks a lot for quickly addressing the issue.

Warm Regards,

- Vikram Lele