Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hello Every1,

I am having trouble using the NATUPnPLib. I have a piece of code that works perfectly fine while the project is running on .Net 4. But, unfortunately when I try the same piece of code in .Net3.5, I get some assembly reference errors while building.

C#
UPnPNATClass upnpnat = new UPnPNATClass();

            IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;


And i get the following build errors:

The type or namespace name 'UPnPNATClass' could not be found (are you missing a using directive or an assembly reference?


Although i have added the reference to the NatUPnP Library from Add Reference --> COM

I have scoured the internet to find a solution but i was unable to find any help. I hope someone here might be able to help out.

P.S: I followed this link

Thanx & Regards,
Umer
Posted
Comments
Andy411 21-Mar-12 4:12am    
You added a reference, but did you add the using directive in your cs-file? Usually at the top of the file. Something like using NATUPnP; just below using System;
Umer Aziz Malik 21-Mar-12 4:14am    
Yes i did. As i said, the same code had been working with .Net 4. But i have to get the project to .Net 3.5 and it is not working there.

Thanx

I just created a little project with .net 3.5 an added a reference to the NATUPNPLib. I opened the object browser but NATUPNPLib doesn't contain a class called UPnPNATClass. And thats's what the error message is saying.
When I change the project to .net 4.0 the class UPnPNATClass exists in the object browser.

It looks like the link you posted only describes a solution for .Net 4.0.

[Edit]Sorry, I posted it as a solution, even if it is not a real solution. But IMO it answers your question.[/Edit]
 
Share this answer
 
v2
Comments
Umer Aziz Malik 21-Mar-12 4:30am    
Thanx for the effort. But i had already checked this myself
And my impression is that the guy in that link is using VS2008 so there might just be a way to make this work
I tried everything possible, and i got to the conclusion that you can't use the method specified above in .NET3.5
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900