Port Forwarding (NAT UPNP) ERROR
Asked Answered
C

1

7

Im trying to set port forwarding using c#, but I keep getting this error in visual studio.

Interop type 'NATUPNPLib.UPnPNATClass' cannot be embedded. Use the applicable interface instead.

this is the code:

NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(9099, "UDP", 9099, "192.168.1.101", true, "Local Web Server");

Any Ideas?

I found the code here.

Culpepper answered 17/3, 2012 at 0:44 Comment(0)
R
7

Find the reference to NATUPNPLib in the solution explorer, select it and in the Properties tab change "Embed Interop Types" to FALSE and then rebuild.

Raviv answered 6/4, 2012 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.