no Events?

Nov 27, 2009 at 1:31 PM

Hi,

i make the following VPN-Connection

// VPN Verbindung aufbauen

RasDialer dialer = new RasDialer();
dialer.EntryName = "SPPVPN";
dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
dialer.DialAsync(new System.Net.NetworkCredential("vpn-user1", "geheim"));

Here my Event Section.

private void rasDialer1_StateChanged(object sender, StateChangedEventArgs e)
{
   tbvpnout.AppendText(string.Format("{0}\r\n", e.State.ToString()));
}

private void rasDialer1_DialCompleted(object sender, DialCompletedEventArgs e)
{
    if (e.Cancelled)
    {
        tbvpnout.AppendText(string.Format("Verbindunggsabbruch\r\n"));
        label10.Text = "Verbindunggsabbruch";
    }
    else if (e.TimedOut)
    {
        tbvpnout.AppendText(string.Format("Zeitüberschreitung\r\n"));
    }
    else if (e.Error != null)
    {
       tbvpnout.AppendText(string.Format("Fehler: {0}\r\n", e.Error.ToString()));
    }
    else
    {
       tbvpnout.AppendText(string.Format("Verbindung ist aufgebaut\r\n"));
    }
}

my Code make a vpn connection. bud i don´t recieve a event for dialcompled
or statuschange.

regards

Thomas Lauer

 

Coordinator
Nov 27, 2009 at 4:11 PM

I can't assume anything and since I don't see in your code anywhere that you connect the event to the method I have to ask... did you forget to connect them together?

dialer.DialCompleted += new EventHandler<DialCompletedEventArgs>(this.rasDialer1_DialCompleted);
dialer.StateChanged += new EventHandler<StateChangedEventArgs>(this.rasDialer1_StateChangedEventArgs);

Nov 29, 2009 at 11:09 AM

Hi Jeff,

thanks for your help. i use the event with the GUI.

Can i send you my sourcecode?

Regards

Thomas

 

 

Coordinator
Nov 29, 2009 at 6:55 PM

Sorry, but I don't repair code from other people... you'll need to fix your own application.

The events from the project are working just fine, I would have heard a lot of complaints if they weren't since all components in the project derive from the RasComponent class which is where the event raising method resides.

Nov 30, 2009 at 7:29 AM

Hi Jeff,

sorry i don´t want to give you my full sourceode for repair. i want to make a small sample for my problem.

The Autoecode Generator from Visual Studio 2008 generate this code.

//
// rasDialer1
// <font size="2">

 

</font>

this.rasDialer1.EapData = null;
this.rasDialer1.DialCompleted += new System.EventHandler<DotRas.DialCompletedEventArgs>(this.rasDialer1_DialCompleted);
this.rasDialer1.StateChanged += new System.EventHandler<DotRas.StateChangedEventArgs>(this.rasDialer1_StateChanged);

 

i found my problem. i forgot the this bevor my code line:

wrong:
tbvpnout.AppendText(string.Format("{0}\r\n", e.State.ToString()));

good:
this.tbvpnout.AppendText(string.Format("{0}\r\n", e.State.ToString()));

Regards
Thomas Lauer

Coordinator
Nov 30, 2009 at 1:11 PM

I'm glad to hear you got it working.