Dial Up connection created , but no internet

Jul 31, 2012 at 7:20 AM
Edited Aug 1, 2012 at 4:59 AM

Hi, 

I am new to this project. I am trying to write program that create a dial up connection and then connect to it. The connection is created and I can connect to it but there is no internet and no ping.  

There is no problem with my internet provider and gsm modem. When I create the dial-up connection with windows every thing is ok.

This is my code 

            this.AllUsersPhoneBook.Dispose();
            this.AllUsersPhoneBook.Open();
            RasDevice dev = RasDevice.GetDevicesByType(RasDeviceType.Modem.ToString())[0];
            RasEntry entry = RasEntry.CreateDialUpEntry(EntryName, "*99#", dev);
            entry.EncryptionType = RasEncryptionType.Optional;
            entry.Options.ModemLights = true;

            entry.NetworkProtocols.IP = true;
            entry.NetworkProtocols.Ipx = false;
            for (int i = 0; i < this.AllUsersPhoneBook.Entries.Count; i++)
            {
                if (this.AllUsersPhoneBook.Entries[i].Name == (entry.Name))
                { this.AllUsersPhoneBook.Entries.Remove(this.AllUsersPhoneBook.Entries[i]); }

            }
            this.AllUsersPhoneBook.Entries.Add(entry);

any one know where the problem is ?

Coordinator
Aug 1, 2012 at 6:33 AM
Edited Aug 2, 2012 at 5:19 AM

Like I tell everyone that is trying to create phone book entries, there are lot of options to choose from. Right now, all you're really doing is guessing which ones you need to set to make the connection successful. In order to ensure a working connection is used I would:

  1. Create a connection in Windows, and dial it with Windows to make sure the connection works.
  2. Dial that same connection in your application using DotRas to ensure what you're passing into the dialer works as you expect.
  3. Use the RasPhoneBook class to open the phonebook containing the connection in step 1 while debugging and write down all the settings that Windows used for your entry (this might take a while).
  4. Replicate the settings identified in step 3 to your code that creates your own custom entry.
  5. Dial that new connection created in step 4 from your application as you tried to do originally.

Generally speaking, following these steps ensures that the connection you're creating doesn't have any problems connecting. Unfortunately this happens quite a bit, there are just so many settings to pick from on the connection it causes a lot of confusion. There isn't much I can do about it from an API design perspective simply because that's all the stuff Windows needs to work.

Good luck!

Edit: Wanted to clarify what I meant in step 3.

Aug 1, 2012 at 7:09 AM
Ok, Step One and two is done, but I dont know any thing about step three can you give me an example about that ?

Editor
Aug 1, 2012 at 7:34 PM

AmirPouya, what I did the first few times I did things like what you're attempting is to literally go through all the windows presented in the phonebook entry created in step 1 and write them all down. Then, run your code without the delete and compare precisely two entries. There are too many settings to possibly remember everything set. (I do find it interesting that the UI and the datastructures behave differently when it comes to defaults, but I guess that's expected ...)