UPnP

Collagar

New member
Joined
Jan 17, 2008
Messages
1
Programming Experience
5-10
I have been trying for quite a while to access my router using UPnP in VB.NET. I know UPnP is active and working (I have explicitly turned the option on in my router and have been able to access it with other applications). I have tried to get access using several classes in VB (UPnPLib, NATUPnPLib etc.), but have not yet been able to display anything. Somewhere in the code it will always generate an error, no matter what I do. Even the simplest code I used gives me an error. In some cases, it just gives me a variable that contains "nothing" (not just an empty variable, but the VB nothing) or it returns the error that it is not set to an instance of an object, eventhough I have used NEW at all possible places. An example:

VB.NET:
Public Class frmMain

    Private uPnpNat As New NATUPNPLib.UPnPNAT

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mapCollection As NATUPNPLib.IStaticPortMappingCollection = uPnpNat.StaticPortMappingCollection

        MsgBox(mapCollection.Item(80, "TCP").Description)
    End Sub

End Class

This gives me the instance error at the "Dim" line. I cannot add the New on that line, as IStaticPortMappingCollection is an interface, which cannot be called with the New statement.

A whole lot of possible approaches can be found all over the internet, but none of them has worked for me. Does anyone have any idea how I could tackle this? All I want to do is forward a port in my router using VB... Any help would be greatly appreciated.

Thanks in advance,
Collagar
 
Back
Top