Thursday, May 13, 2010

Using DotRas

In those days I'm trying to use DotRas library in my WPF project. DotRas is a fantastic library that let you create and use a RAS/VPN connection.. In my scenario I have one application that has to activate a 3G connection (using an USB modem )in order to contact a WCF data service.
I downloaded DotRas 1.1 from the official codeplex website (dotras.codeplex.com) and I added a reference on my WPF app.. The code is quite simple:

using DotRas;

....

RasDialer dialer;

private void Connect()
{
dialer = new RasDialer();
dialer.PhoneBookPath = @"C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk";
dialer.EntryName = "TEST";
dialer.Dial();
}

Before start the program you have to create the PhoneBookEntry double clicking on rasphone.pbk or in XP Start-->Settings-->Control Panel-->Network Connection:
  • create a New Connection
  • Select the Connect to the Internet --> Next
  • Select Set up my connection manually --> Next
  • Select Connect using a dial-up modem --> Next
  • Select the modem to be used --> Next
  • Type the ISP name that must be the dialer.EntryName --> Next
  • Type the Phone number depending on your ISP. For the provider I'm using is *99# --> Next
  • Fill the account information depending on your ISP --> FINISH!
DotRas can also help to create the network connection programmatically in the code, but in my case I don't need this..

1 comment: