VPN and Registry

Mar 16, 2011 at 11:31 PM

When I execute My project, I make a new VPN connection named PrivateVPN

using the Add Method             Me.AllUsersPhoneBook.Entries.Add(EntryName)

and before closing the program I delete it with           Me.AllUsersPhoneBook.Entries.Remove(EntryName)

Everything seems to work fine, but the second time I execute my program I found a vpn connection called PrivateVPN # 2 and the third time one called PrivateVPN # 3 and so on

I think that Remove method doesn't clean some registry key. There are some other methods to clean completly the added VPN?

Coordinator
Mar 19, 2011 at 5:12 PM

The project only ties into the Windows API, and since entries are no longer stored in the registry (they're in pbk files as of Windows 2000) I don't know what would cause the problem you're seeing. With the amount of users on this product and you being the only person that's reported this in 2 years, I'm lead more to believe you need to look at your application and how you're using the project rather than the project itself being the problem.

Good luck with your project!

Mar 20, 2011 at 6:55 PM

Hi Jeff, thanks for your reply. I'm sure that problem is not your project. My doubt is in the way I use it.

This is the code I use to Create a VPN connection

        Me.AllUsersPhoneBook.Open()
        Dim entry As RasEntry = RasEntry.CreateVpnEntry(EntryName, IPEntryVPN, RasVpnStrategy.Default, RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn))
        entry.Options.RemoteDefaultGateway = False
        entry.Options.RequireMSChap = True
        entry.Options.RequireChap = True
        entry.Options.RequirePap = True
        entry.EncryptionType = RasEncryptionType.Optional
        Me.AllUsersPhoneBook.Entries.Add(entry)

And this is the code I use to remove VPN entry.

            Me.Dialer.Dial.Close()
            Me.Dialer.Dial.Dispose()
            Me.AllUsersPhoneBook.Entries.Remove(EntryName)

In your opinion there is something wrong ?

Coordinator
Mar 21, 2011 at 2:20 AM

Directly no, it could be whatever is setting EntryName. Don't forget, you can always use a custom phone book next to your app and not have to add and remove the entry constantly.