Я пытаюсь создать программу, которая будет отображать порты на мой маршрутизатор uPnP, так как мои порты постоянно перезагружаются, и я не могу подключиться к моему дому. Я создаю (более похожий на скопированный) следующий код, и я всегда получаю сообщение об ошибке при нажатии кнопки.Ошибка uPnP и .Net
Код:
Imports NATUPNPLib
Public Class Form1
Dim entry As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
Dim upnp As New NATUPNPLib.UPnPNAT
Dim portmaps As NATUPNPLib.IStaticPortMappingCollection = upnp.StaticPortMappingCollection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
portmaps.Add("5901", "TCP", "5901", "10.175.3.22", True, "VNC")
End Sub
End Class
И ошибка:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80040208): A user-supplied component or subscriber raised an exception (Exception from HRESULT: 0x80040208)
at NATUPNPLib.IStaticPortMappingCollection.Add(Int32 lExternalPort, String bstrProtocol, Int32 lInternalPort, String bstrInternalClient, Boolean bEnabled, String bstrDescription)
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Как я не самый опытный в .NET, есть ли какие-нибудь предложения?