奇怪的兼容性问题与.net 3.5和4.0组件(NATUPnPLib)组件、奇怪、兼容性问题、net

2023-09-03 05:02:11 作者:孤身一人

我遇到了麻烦NATUPnP 1.0类型库与框架3.5在Visual Studio 2010中工作,如果我使用的.Net 4.0,它工作得很好,但是与.net 3.5,NATUPNPLib的命名空间看起来的 excactly 像NETCONLib的。

I'm having trouble getting NATUPnP 1.0 Type Library to work with Framework 3.5 in Visual Studio 2010. If I use .Net 4.0, it works just fine, but with .Net 3.5, NATUPNPLib's namespace looks excactly like NETCONLib's.

例如从本网站这个端口转发管理应用程序的示例:http://pietschsoft.com/post/2009/02/05/NET-Framework-Communicate-through-NAT-Router-via-UPnP.aspx

For example this Port Forwarding Management Application sample from this site: http://pietschsoft.com/post/2009/02/05/NET-Framework-Communicate-through-NAT-Router-via-UPnP.aspx

..是使用.net 3.5,但我不能让它在Visual Studio 2010中编译,除非我改变它到.NET 4.0。 我没有试过,但我敢打赌,在Visual Studio 2008就没有问题。

..is using .Net 3.5, but I can't get it to compile in Visual Studio 2010 unless I change it to .Net 4.0. I haven't tried, but I bet in Visual Studio 2008 there would be no problems.

推荐答案

我部分摄制。我也得到两个截然不同的互操作库,但我这样做是在两个VS2008和VS2010。仔细看的添加引用+ COM选项卡,路径列。 他们都指的是同一个DLL,C:\ WINDOWS \ SYSTEM32 \ hnetcfg.dll的

I partly repro. I too get two distinct interop libraries but I do so on both VS2008 and VS2010. Take a close look at the Add Reference + COM tab, Path column. Both of them refer to the same DLL, c:\windows\system32\hnetcfg.dll".

嗯,这是有道理的,相同的互操作的库会从同一个DLL生成。我猜想,有人在微软决定的类型库的名字之一是照出,改变了注册程序以新名称进行注册。 和的注册它在旧的名字,这样不会破坏向后兼容性。它不知道,但CON是那些神秘的缩写词之一(?),可以始终对微软的类型库的名字突然出现了一遍又一遍。 UPNP指甲下更好的工作,我想。

Well, it makes sense that the same interop library gets generated from the same DLL. I would guess that somebody at Microsoft decided that one of the type library names was crummy and changed the registration procedure to register it under a new name. And register it under the old name so not to break backward compatibility. Not sure which, but "CON" is one of those mysterious acronyms (?) that keeps popping up over and over again on Microsoft type library names. "UPNP" nails the job down better, I guess.

有可能是一个区别,如果你运行64位操作系统。 不要的挑名称VS2010显示。否则,有一个在引用相同的类型库到同一个COM服务器两次毫无意义。一会完成这项工作。

There might be a difference if you run a 64-bit operating system. Do pick the name that VS2010 shows. Otherwise, there's no point in referencing the same type library to the same COM server twice. One will get the job done.