On Win7 64bit , PPPOE Not Work

Mar 3, 2012 at 1:13 AM
Edited Mar 3, 2012 at 1:19 AM

code example:


 RasPhoneBook book = new RasPhoneBook();
            string name = "abcd";
            if (book.Entries.Contains(name)) {

            RasEntry entry = RasEntry.CreateDialUpEntry(name, "111111", RasDevice.GetDeviceByName("(PPPOE)", RasDeviceType.PPPoE));
            RasEntryOptions options = new RasEntryOptions();
            options.RequirePap = true;
            options.RequireSpap = true;
            options.RequireChap = true;
            options.RequireMSChap = true;
            options.RequireWin95MSChap = true;
            options.RequireMSChap2 = true;

            entry.Options = options ;

            RasDialer dial = new RasDialer();
            dial.EntryName = name;
            dial.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);

            dial.Credentials = new System.Net.NetworkCredential("****", "******");



The red part is invalid 。 but it work on xp good. help me , thanks . waiting online.

Mar 3, 2012 at 5:24 PM
Edited Mar 3, 2012 at 5:27 PM

First, you should be using the CreateBroadbandEntry method for PPPOE connections, yes they are considered a dial-up connection but the default entry options used for PPPOE connections are different than those used by a normal dial-up connection.

This is an example of what you should be using to create the entry:

RasEntry entry = RasEntry.CreateBroadbandEntry("Broadband Connection", RasDevice.GetDeviceByName("(PPPOE)", RasDeviceType.PPPoE);

Also, the call where you're setting the options property on the RasEntry object should be avoided. All you've done is clear the options which are set internally in the RasEntry static method used earlier, making the entry unusable in most circumstances.

This is an example of how to correctly set the options on the entry:

entry.Options.RequirePap = true;
entry.Options.RequireSpap = true;

If you have to change the options, setting each option manually rather than setting the options object to your own new instance of RasEntryOptions will have better success with the entry working as expected. Yes the property set accessor is exposed for people who know what they're doing with the options, but you've pretty much cleared everything that needed to be set for the entry to work. I'm kind of surprised that the entry worked at all.

Edit: I want to be clear, the above options I've changed may NOT be needed for other situations. Those options are being set to demonstrate how to properly set the options using examples the original poster had used.