DialUp Connection Exception

Jun 8, 2011 at 9:48 AM

Hi Jeff,

my application should be able to establish a dialup connection, so I've tried it with this quick code.

using (RasDialer dialer = new RasDialer()) 
            {
                RasPhoneBook book = new RasPhoneBook();
                book.Open();
                RasEntry entry = book.Entries[0];
                dialer.EntryName = entry.Name;
                //MessageBox.Show(entry.Name);
                dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User); 
                dialer.Credentials = new NetworkCredential("tmobile","tmobile");
                dialer.DialAsync();
            }

I get an Exception with this code, so I've checked the output from entry name and it displays me the connection with the right name which I've created with Windows "Tools".

Dialing with rasdial.exe over command line works normally.

Thanks for your help.

Björn

Coordinator
Jun 8, 2011 at 3:39 PM

Hi Björn,

It looks like you're using the all users phonebook to store the connection as indicated by your book.Open() call, and you're passing the current user profile phonebook to the dialer from the GetPhoneBookPath(RasPhoneBookType.User) call. As indicated in the documentation, there are two phone books in use by Windows. You just have to make sure you're passing the correct path to the dialer so it knows where to look. The easy fix would be to change your code to:

dialer.PhoneBookPath = book.Path;

That should take care of the error you may be seeing. If it does not, you'll need to tell me what exception you're getting rather than just telling me there's a problem.

Hope that helps!

Jeff 

Jun 9, 2011 at 11:26 AM

Hi Jeff,

it's working great now, thank you. I'm currently logged in as admin, bad mistake :)

Now it's really funny coding with your lib, easy to use.

Best Regards

Björn