RasDialer Class

DotRas SDK

Collapse image Expand Image Copy image CopyHover image
Provides an interface to the remote access service (RAS) dialer. This class cannot be inherited.

Namespace: DotRas
Assembly: DotRas (in DotRas.dll) Version: 1.3.5166.33435 (1.3.0.0)

Syntax

C#
public sealed class RasDialer : RasComponent
Visual Basic
Public NotInheritable Class RasDialer
	Inherits RasComponent
Visual C++
public ref class RasDialer sealed : public RasComponent
F#
[<SealedAttribute>]
type RasDialer =  
    class
        inherit RasComponent
    end

Remarks

Failure to dispose of this component may result in a connection attempt hanging, which will require the machine to be restarted before the connection is released.

When using RasDialer to dial connections asynchronously, ensure the SynchronizingObject property is set if thread synchronization is required. If this is not done, you may get cross-thread exceptions thrown from the component. This is typically needed with applications that have an interface; for example, Windows Forms or Windows Presentation Foundation (WPF).

If an exception occurs while processing an event while dialing asynchronously, that exception will be raised through the Error event on RasDialer. This approach allows the application to continue processing the notifications from Windows, which would otherwise cause the state machine to be corrupted and require the machine to be rebooted.

The events raised by this component occur only during a dialing operation, if you need to monitor connection changes made outside of dialing a connection use the RasConnectionWatcher component.

Known Limitations

  • Due to limitations with Windows, RasDialer cannot handle expired passwords or have the ability to change a password while connecting.
  • This component can only handle dialing one connection at a time. If your application needs to dial multiple connections simultaneously, use multiple instances of the component.

Examples

The following example shows how to use a RasDialer component to synchronously dial an existing entry.
C# Copy imageCopy
using (RasDialer dialer = new RasDialer())
{
   dialer.EntryName = "My Connection";
   dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers);
   dialer.Credentials = new NetworkCredential("Test", "User");
   dialer.Dial();
}
Visual Basic Copy imageCopy
Dim dialer As RasDialer
Try
   dialer = New RasDialer
   dialer.EntryName = "My Connection"
   dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers)
   dialer.Credentials = new NetworkCredential("Test", "User")
   dialer.Dial()
Finally
   If (dialer IsNot Nothing) Then
       dialer.Dispose()
   End If
End Try

Inheritance Hierarchy

See Also