急救!upnp静态端口映射
我开发机win7,使用vs2010
<1>创建工程,引用COM组件NATUPnP 1.0 Type Library (c:\windows\system32\hnetcfg.dll)
<2>在代码中引入命名空间“NATUPNPLib”
<3>声明静态对象:static UPnPNATClass nat = new UPnPNATClass();
<4>添加静态端口映射:
nat.StaticPortMappingCollection.Add(9527, "UDP", "9527", "192.168.0.112", true, "test");
报:StaticPortMappingCollection为null
在网上看大家都是这么做的,也没看出来有啥特殊,为啥我的为null?????
急救!