Port Forwarding (NAT UPNP) ERROR

I am 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 .

+6
source share
1 answer

Find the NATUPNPLib link in the solution explorer, select it, and on the Properties tab, change "Insert Interaction Types" to FALSE and then rebuild.

+6
source

Source: https://habr.com/ru/post/910961/


All Articles