ArgumentException when redial again

May 24, 2013 at 12:41 AM
Edited May 24, 2013 at 12:42 AM
I am going to make a VPN client, with PPTP,L2TP,SSTP choice.

the client works well at the first time, but it fail to dial again when open this software second time, it shows:
System.ArgumentException: 'entry' must have the PhoneNumber, DeviceType, DeviceName, FramingProtocol, and EntryType properties set as a minimum.
I will update the entry if it exist with the new server address, and devicetype, here is my code:
 Me.RasPhoneBook2.Open()
        If (RasPhoneBook2.Entries.Contains(EntryName)) Then
            'RasPhoneBook2.Entries.Remove(EntryName)
            entry = RasPhoneBook2.Entries(EntryName)
            If chbL2TP.Checked = True Then
                entry.PhoneNumber = loginserver
                entry.VpnStrategy = RasVpnStrategy.L2tpOnly
            ElseIf chbSSTP.Checked = True Then
                entry.PhoneNumber = loginserver
                entry.VpnStrategy = RasVpnStrategy.SstpOnly
            ElseIf chbSSH.Checked = True Then

            Else
                entry.PhoneNumber = loginserver
                entry.VpnStrategy = RasVpnStrategy.PptpOnly
                chbPPTP.Checked = True
            End If
            entry.Update()
        Else
            If chbSSTP.Checked = True Then
                entry = RasEntry.CreateVpnEntry(EntryName, loginserver, RasVpnStrategy.SstpOnly, RasDevice.GetDeviceByName("(SSTP)", RasDeviceType.Vpn))
            ElseIf chbL2TP.Checked = True Then
                entry = RasEntry.CreateVpnEntry(EntryName, loginserver, RasVpnStrategy.L2tpOnly, RasDevice.GetDeviceByName("(L2TP)", RasDeviceType.Vpn))
            Else
                entry = RasEntry.CreateVpnEntry(EntryName, loginserver, RasVpnStrategy.PptpOnly, RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn))
            End If

            ' Add the new entry to the phone book.
            Me.RasPhoneBook2.Entries.Add(entry)
        End If
what am I missing?
thanks
May 24, 2013 at 12:43 AM
i;ve tried add
RasPhoneBook2.Entries.Remove(EntryName)
and it works for WinXP and Win8, but there is an annoying pop window for the new connection after connected every time in Win7.
Jun 4, 2013 at 3:29 AM
Can anybody help me?
The code works fine for winxp and win8, except win7.
The error will occur even with the administrator role.
Editor
Jun 6, 2013 at 5:47 PM
If you mean the NLA in 7, I think you can turn that off with a registry key. Nothing to do with RAS.