I tried to implement port forwarding, but stopped at this step and cannot understand what the problem is.
UPnPNATClass upnpnat = new UPnPNATClass(); IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection; // Выбрасывает null
I tried to implement port forwarding, but stopped at this step and cannot understand what the problem is.
UPnPNATClass upnpnat = new UPnPNATClass(); IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection; // Выбрасывает null
Check that the router has UPNP enabled and that you have the necessary permissions. Most likely the problem is this.
It is also said that if you are using .NET 4.0 and higher, adding this section to app.config may help:
<startup uselegacyv2runtimeactivationpolicy="true">
Well, if nothing helps, you can try Open.NAT .
Source: https://ru.stackoverflow.com/questions/497402/
All Articles