This project is read-only.

win2003 - Update phone book error?

Nov 7, 2009 at 9:45 PM

Hi guys,

Been playing around with this great library but I've got a small problem.... I've wrote some code that creates a VPN connection when it starts.... I've developed the program on Windows Vista on VS2008, but when I try run the exe on my 2003 server I get the following error:

"The system could not update the phone book file"

I did some playing around with the code and found it fails when I try change the options... In specific, remove the Default Gateway Option....

var _book = new RasPhoneBook();
_book.Open(false);

try
{
	var _newEntry = RasEntry.CreateVpnEntry("Test1", "xxxx", RasVpnStrategy.PptpOnly, RasDevice.GetDeviceByName("PPTP", "vpn"));	
	_book.Entries.Add(_newEntry);
	
	_newEntry.Options = _newEntry.Options & ~RasEntryOptions.RemoteDefaultGateway;
	_newEntry.UpdateCredentials(new NetworkCredential("xxxx", "xxxxx"));	
	_newEntry.Update();
}
catch (Exception error)
{
	MessageBox.Show(error.ToString());
}
If I comment out the .Options change it will work..... but the VPN connection will be incorrect.... Any ideas why this is?
Cheers guys!
Will
Nov 8, 2009 at 3:36 AM

Which version of the project are you using? (WIN2K, WINXP, WINXPSP2, or WIN2K8)

Nov 8, 2009 at 11:56 AM

WINXPSP2....

I've done some more testing and found a solution..... If I stick a Thread.Sleep in before trying to update the phonebook it seems to work! Maybe PC is running a little slow and not inserting the phone book entry into the phone book before trying to update it? Is this something you have come across before?

Nov 8, 2009 at 2:23 PM
Edited Nov 8, 2009 at 3:42 PM

If it were me I'd change the options before I added it to the phone book. You'll be able to remove the Update() call since UpdateCredentials does not require you to call Update().

Give that a shot and see if it helps.

Edit: Forgot to answer your question at the end.. I haven't heard any reports of anything like this happening, and I know people are using the project like this.

Nov 8, 2009 at 5:09 PM

that works perfectly! thanks so much for your help! :-)

Cheers
Will

Nov 8, 2009 at 6:15 PM

Glad to hear it! Let me know if you encounter any more problems.