0

I am using vb.net with the DotRas SDK https://archive.codeplex.com/?p=dotras I have a problem, if I try to execute the example, I always get the error "The value 'gre' is not supported for conversion."

It must be an error with the call

RasDevice.GetDevice

The complete call is:

Dim entry As RasEntry = RasEntry.CreateVpnEntry(EntryName, IPAddress.Loopback.ToString(), RasVpnStrategy.Default, RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn))

Has anyone an idea, what the problem could be, or how it can be fixed?

I am using Windows Server 2016 64Bit

Thanks!

Edit:

Public Class MainForm
    Public Const EntryName As String = "VPN Connection"
    Private connectionHandle As RasHandle

    Private Sub CreateEntryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateEntryButton.Click
        ' This opens the phonebook so it can be used. Different overloads here will determine where the phonebook is opened/created.
        Me.AllUsersPhoneBook.Open()

        Dim device = RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn)
        Dim entry = RasEntry.CreateVpnEntry(EntryName, IPAddress.Loopback.ToString(), RasVpnStrategy.Default, device)


        ' Add the new entry to the phone book.
        Me.AllUsersPhoneBook.Entries.Add(entry)
    End Sub
Manuel
  • 613
  • 1
  • 6
  • 20
  • Break your one line into 2: `Dim device = RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn)` and `Dim entry = RasEntry.CreateVpnEntry(EntryName, IPAddress.Loopback.ToString(), RasVpnStrategy.Default, device)`. Does the first line execute? (test your theory about that call being the one which fails. If it works, then its somewhere else. (this is just basic debugging) – djv Jun 04 '19 at 17:58
  • There is also a parameter used with `GetDeviceByName` called exactMatchOnly. In the sample video on the page you linked @ 2:23 `false` is passed as an argument. – djv Jun 04 '19 at 18:01
  • The video also shows `this.rasPhoneBook1.Open()` called beforehand. It must be a control on the form in the example. Please be sure to include all your relevant code. – djv Jun 04 '19 at 18:03
  • Hello, I added the whole relevant code in my first post (it's the example code from the archive). As you suggested I broke the line into two, and it still fails with Dim device = RasDevice.GetDeviceByName("(PPTP)",RasDeviceType.Vpn). I also tried to add "false in the GetDeviceByName call, but it didn't change anything, the error is still the same. Thank you for your help! – Manuel Jun 04 '19 at 18:40
  • I ran the example on my machine and it works. It returns the "WAN Miniport (PPTP)" connection. Maybe it's unavailable on your system. Make sure it's there and enabled. Follow [this tutorial](https://social.technet.microsoft.com/Forums/windows/en-US/9aaaa123-69c2-43f0-9ba1-b63e7666f858/vpn-issue-with-miniport-pptp?forum=w7itpronetworking) – djv Jun 04 '19 at 20:49
  • I have "WAN Miniport (PPTP)" enabled and active, but I have also "WAN Miniport (GRE)" on my system, do you also have this entry? Deactivating this entry via the device manager, doesn't change anything – Manuel Jun 04 '19 at 20:55
  • yes actually I have 9 "WAN Miniport ..." total. I don't know why else it doesn't work for you. I'll point out that I couldn't execute this line `Me.AllUsersPhoneBook.Open()` because of permissions issues on my local machine, so everything I got working was without that line – djv Jun 04 '19 at 21:00
  • Oddly, the `GetDeviceByName` is deprecated in the API I downloaded. I can run `Dim devices = RasDevice.GetDevices()` and see 10 device on my system. Does that work for you? – djv Jun 04 '19 at 21:02
  • Do you run this on Windows 10? because on Windows 10 I also got that permission issue. If I run Dim devices = RasDevice.GetDevices() I get the same error, I already tested this :( If I run the same example on my Windows 10 machine, I get no errors, so it must be a problem with the Windows Server. Any suggestions, how to find that issue? – Manuel Jun 04 '19 at 21:07
  • Yes on Windows 10. Are you using the NuGet package for Windows 8? – djv Jun 04 '19 at 21:17
  • I've just opened the WinForms example project from the latest release in the archive. This uses the DotRas.dll from 22 February 2014 – Manuel Jun 04 '19 at 21:21
  • It looks to the same as NuGet Windows 10 but he has published different versions for a reason I guess. Try different versions on NuGet. There are: `DotRas.for.Win2K`, `...WinXP`, `...Win2K8`, `...Win7`, `...Win8`. Possibly one of the others will work on your Windows Server – djv Jun 04 '19 at 21:26
  • I tried each of the 5 NuGet Packages, but the error is still the same, no matter which package I take :/. – Manuel Jun 05 '19 at 18:02
  • (I am far from an expert on this btw). Had to Google [GRE](https://en.wikipedia.org/wiki/Generic_Routing_Encapsulation) even. Maybe if you are using GRE then this isn't the right library for you. – djv Jun 05 '19 at 18:13
  • I don't want to use GRE, I don't even need all these adapters including GRE, I don't know why the error occurs and it writes "gre", do you have any more hints for me? I don't know how to find the issue. – Manuel Jun 06 '19 at 20:32
  • Can you use a different library? Can you disable the GRE adapter in device manager? – djv Jun 06 '19 at 20:39
  • I haven't found any different library which I can use to create and manage RAS connections, do you know any? I already tried to disable the GRE adapter, but it doesn't change anything, the error still stays the same. – Manuel Jun 07 '19 at 19:30
  • No honestly I don't know much about this stuff past `vb.net` itself, but you could try rasdial, see [this](https://stackoverflow.com/a/7079288/832052) – djv Jun 07 '19 at 19:54
  • As far as I know I can use rasdial to dial an existing entry in the ras phonebook, but I can not add an entry into the phonebook, especially if I would like to use some special paramaters like setting the ip address etc. EDIT: I found some updated dotras on github, I will try to use this one and check if it helps https://github.com/winnster/DotRas – Manuel Jun 07 '19 at 22:25

1 Answers1

0

Unfortunately the old API cannot handle unexpected values coming from Windows in this are of the newer types of devices.

You will need to likely upgrade to the 2.0 version that does support it (however they are in preview right now).

The project site also moved to GitHub at https://github.com/winnster/DotRas if you’re interested.

Jeff Winn
  • 804
  • 8
  • 14