【问题标题】:DotRas Error "The value 'gre' is not supported for conversion."DotRas 错误“不支持转换值 'gre'。”
【发布时间】:2019-10-20 05:27:08
【问题描述】:

我正在使用带有 DotRas SDK https://archive.codeplex.com/?p=dotras 的 vb.net 我有一个问题,如果我尝试执行该示例,我总是收到错误“不支持转换值 'gre'。”

一定是调用出错

RasDevice.GetDevice

完整的调用是:

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

有没有人知道问题可能是什么,或者如何解决?

我使用的是 Windows Server 2016 64 位

谢谢!

编辑:

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

【问题讨论】:

  • 将一行分成两行:Dim device = RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn)Dim entry = RasEntry.CreateVpnEntry(EntryName, IPAddress.Loopback.ToString(), RasVpnStrategy.Default, device)。第一行是否执行? (测试你关于那个调用失败的理论。如果它有效,那么它在其他地方。(这只是基本的调试)
  • 还有一个与GetDeviceByName 一起使用的参数称为exactMatchOnly。在您链接的页面上的示例视频中 @ 2:23 false 作为参数传递。
  • 该视频还显示了this.rasPhoneBook1.Open() 事先调用。它必须是示例中窗体上的控件。请务必包含所有相关代码。
  • 您好,我在第一篇文章中添加了整个相关代码(这是存档中的示例代码)。正如你所建议的,我将线路一分为二,但仍然因 Dim device = RasDevice.GetDeviceByName("(PPTP)",RasDeviceType.Vpn) 而失败。我也尝试在 GetDeviceByName 调用中添加“false”,但它没有改变任何东西,错误仍然相同。谢谢您的帮助!
  • 我在我的机器上运行了这个例子,它可以工作。它返回“WAN Miniport (PPTP)”连接。也许它在您的系统上不可用。确保它在那里并启用。关注this tutorial

标签: vb.net dotras


【解决方案1】:

很遗憾,旧 API 无法处理来自 Windows 的意外值,因为这是较新类型的设备。

您可能需要升级到支持它的 2.0 版本(不过它们现在处于预览阶段)。

如果您有兴趣,该项目网站也已移至 GitHub https://github.com/winnster/DotRas

【讨论】:

    猜你喜欢
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-09
    • 2010-10-04
    • 2022-12-22
    • 2017-08-11
    • 1970-01-01
    相关资源
    最近更新 更多