Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird compatibility problem with .Net 3.5 and 4.0 assemblies (NATUPnPLib)

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.

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

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

like image 680
Juha Avatar asked May 15 '10 22:05

Juha


1 Answers

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".

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.

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.

like image 58
Hans Passant Avatar answered Nov 01 '22 12:11

Hans Passant