How to disable "use dialing rules" in a modem RasEntry?

Jan 19, 2011 at 8:33 AM

I just found this SDK last weekend, it's great that it would simplify my work on a modem dialing connection management program.

But after I created an entry in my custom RasPhoneBook, I open the rasphonebook file in windows, I found "use dialing rules" is always checked.

I didn't found a property or method in RasEntry Class to disable this in the documentation. Could someone told me how to disable the "use dialing rules"?

Thanks in advance, and the following is my code to create an entry:

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open(Application.StartupPath + "\\Modem_Dial-up_PhoneBook.pbk");

RasEntry pbkentry=new RasEntry("Modem Dial-up ("+textBox_Dial_Number.Text+")");
pbkentry.PhoneNumber=textBox_Dial_Number.Text;
pbkentry.Device = RasDevice.GetDeviceByName(comboBox_Modem.SelectedItem.ToString(), "modem", true);
pbkentry.FramingProtocol = RasFramingProtocol.Ppp;
pbkentry.Options.SoftwareCompression=true;
pbkentry.Options.DisableLcpExtensions=false;
pbkentry.Options.DoNotNegotiateMultilink=true;
pbkentry.EntryType = RasEntryType.Phone;
pbkentry.NetworkProtocols.IP = true;

pbk.Entries.Add(pbkentry);
Coordinator
Jan 20, 2011 at 5:06 AM

I took a look in the code, and it looks like I hid the option that allowed you to manually enable or disable the dialing rules setting. The idea was that if you were to set either the country id, country code, or area code it would enable the dialing rules. The problem seems to be that the AreaCode is always string.Empty and the code checks whether it's null... thus always enabling the checkbox.

using (RasPhoneBook pbk = new RasPhoneBook())
{
    pbk.Open();

    RasEntry entry = pbk.Entries["Dial-Up Connection"];
    if (entry != null)
    {
        entry.CountryId = 0;
        entry.CountryCode = 0;
        entry.AreaCode = null;
        entry.Update();
    }
}

I'll have to expose the property again because the checkbox can be disabled while any of the country id, country code, and area code properties have been set. The above workaround will allow you to disable the dialing rules until I get the problem fixed... you just need to set the CountryId, CountryCode, and AreaCode properties as shown above anytime you call the Update method on the entry or add it to a phone book. Windows will set the AreaCode property back to string.Empty when the phonebook is opened, which is why it must be changed back before persisting.

Coordinator
Jan 20, 2011 at 5:10 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.