首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Mono.nat的NewPortMappingIndex无效

使用Mono.nat的NewPortMappingIndex无效
EN

Stack Overflow用户
提问于 2013-09-26 14:21:34
回答 1查看 364关注 0票数 0

我正在尝试打开端口,使用UPNP来完成此操作,我正在使用mono.nat

这是我的代码,它很简单,应该可以工作,但它在for each上抛出了“error402: Invalid NewPortMappingIndex”。"device“的各种其他功能与GetExternalIP类似。

代码语言:javascript
复制
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    AddHandler NatUtility.DeviceFound, AddressOf DeviceFound
    NatUtility.StartDiscovery()
End Sub

Private Sub DeviceFound(ByVal sender As Object, ByVal e As Mono.Nat.DeviceEventArgs)
    Debug.WriteLine("Found")
    Dim device As INatDevice = e.Device
    Debug.WriteLine(device.GetHashCode)
    For i = 0 To device.GetAllMappings.Length - 1
        Dim _PortMap As Mono.Nat.Mapping = device.GetAllMappings(i)
        ListBox1.Items.Add(_PortMap.Description & " | " & _PortMap.PrivatePort & " | " & _PortMap.Protocol & " | " & _PortMap.PublicPort)
    Next

End Sub

我还试着关闭防火墙和任何其他可能会干扰的东西。我还知道我的路由器启用了UPNP。

EN

回答 1

Stack Overflow用户

发布于 2013-09-26 15:02:19

这似乎循环了太多次:

对于i=0到device.GetAllMappings.Length

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19020786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档