Is there a UPnP Library for .NET (C# or VB.NET)? [closed]
Asked Answered
T

9

42

I'm working on a P2P application, and I need to get it to communicate through NAT Routers / Firewalls using UPnP. However, it doesn't seem that the .NET Framework includes support for UPnP.

Is there a UPnP Library for .NET? C# or VB.NET?

UPDATE: I have since found the NATUPnP 1.0 Type Library (NATUPNP.DLL) COM Component that is part of Windows (since Windows XP) that allows you to easily setup/maintain Port Forwarding using UPnP.

I wrote an article with code samples here: .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play)

Tamarind answered 2/12, 2008 at 4:47 Comment(2)
Hey thank you for the exhaustive article and the project. I am trying it out and it works brilliantly on a 32bit Win7 system - however on a 64bit Win7 system, UPnPNATHelper.StaticPortMappings is always NULL. Would you have any insights on this?Deen
The link in Chris post has rotted. Here's a fresh link: pietschsoft.com/post/2009/02/05/…Dacoity
P
21

There is a COM library that's easy enough to access:

UPnP APIs Purpose

The UPnP™ framework enables dynamic networking of intelligent appliances, wireless devices, and PCs. There are two APIs for working with UPnP-certified devices:

The Control Point API, which consists of a set of COM interfaces used to find and control devices. The Device Host API, which consists of a set of COM interfaces used to implement devices that are hosted by a computer.

Paxton answered 2/12, 2008 at 4:57 Comment(3)
I wrote an article with code samples here: .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play) - pietschsoft.com/…Tamarind
@ChrisPietschmann link is dead as of Sept 14, 2012Pepin
@Urda, the link is working (again). The Wayback Machine link: web.archive.org/web/20130813184633/http://pietschsoft.com/post/…Foetation
S
25

I have a written a fully Managed UPnP library around the microsoft UPnP Control Point COM objects, its available with full source and a demo project, you can download it from a GitHub repository here:

https://github.com/jogibear9988/ManagedUPnP

It supports full traversal of the UPnP description documents using an object heirachy and among other things is very easy to use.

Soccer answered 20/5, 2011 at 5:59 Comment(3)
This looks very promising, I'll give this a go in my project.Shutt
it's nice, but the underlying objects seem broken. device finder never sends the discovery packet.Repetend
@Aaron Murgatroyd Your link is dead. Here's a git hub fork: github.com/jogibear9988/ManagedUPnPDacoity
P
21

There is a COM library that's easy enough to access:

UPnP APIs Purpose

The UPnP™ framework enables dynamic networking of intelligent appliances, wireless devices, and PCs. There are two APIs for working with UPnP-certified devices:

The Control Point API, which consists of a set of COM interfaces used to find and control devices. The Device Host API, which consists of a set of COM interfaces used to implement devices that are hosted by a computer.

Paxton answered 2/12, 2008 at 4:57 Comment(3)
I wrote an article with code samples here: .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play) - pietschsoft.com/…Tamarind
@ChrisPietschmann link is dead as of Sept 14, 2012Pepin
@Urda, the link is working (again). The Wayback Machine link: web.archive.org/web/20130813184633/http://pietschsoft.com/post/…Foetation
D
8

Mono.Nat is a pretty good library for upnp, at least for my case I had less issues with it so far than when I was using NATUPnP.

You can download it here and you can find a decent tutorial on how to operate it at http://www.fluxbytes.com/csharp/upnp-port-forwarding-the-easy-way/

Delegate answered 13/7, 2012 at 14:8 Comment(0)
H
5

This Intel UPnP tools have been re-released as open source tools at: http://opentools.homeip.net. The new tools are called the "Developer Tools for UPnP technologies". They are built in C# but there is a free code generator that will output C and C# stacks. The C stack will work on Windows and Linux.

Ylian

History answered 13/12, 2009 at 0:23 Comment(1)
@History Yilan, you really need to turn this stuff into a COM .dll or .ocx so people using VB6 or Delphi (or any other non.NET Win32 designer) can use all this work you've put into it. The current upnp.dll is a nightmare of a control and I wouldn't wish having to use it on my worst enemy, please create a Com Wrapper at least.Comitative
O
5

Was looking around for this stuff personally and found::

mono-upnp:: https://github.com/mono/mono-upnp

Mono.Nat:: https://github.com/mono/Mono.Nat

Oilcup answered 1/3, 2012 at 0:10 Comment(0)
T
3

I use this, which seems to work fine:

http://code.google.com/p/dotnetportmapper/

Terreverte answered 6/12, 2008 at 22:57 Comment(0)
D
3

Intels UPNP Tools used to be able to export UPnP clients in C#. The suite is deprecated but ought still work.

Decussate answered 11/2, 2009 at 0:24 Comment(0)
P
3

If someone needs an easy library, I wrote a c# class library that uses the UPnPLib COM component. It has some basic functions to open and close ports. I haven't tested it on multiple platforms yet, but it works on Visual Studio 2010 in Windows 7. Feel free to download it at http://sourceforge.net/projects/easyupnp/

Pettus answered 2/1, 2011 at 11:0 Comment(1)
github.com/meehi/EasyUPnPDenson
C
3

For NAT specifically there is Mono.Nat.

Certified answered 21/2, 2011 at 17:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.