是否有适用于 .NET(C# 或 VB.NET)的 UPnP 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/333079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 10:44:01  来源:igfitidea点击:

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

.netnetworkingupnp

提问by Chris Pietschmann

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.

我正在开发一个 P2P 应用程序,我需要让它使用 UPnP 通过 NAT 路由器/防火墙进行通信。但是,.NET Framework 似乎不包括对 UPnP 的支持。

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

是否有适用于 .NET 的 UPnP 库?C# 还是 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.

更新:此后我发现了 NATUPnP 1.0 类型库 (NATUPNP.DLL) COM 组件,它是 Windows(自 Windows XP 起)的一部分,它允许您使用 UPnP 轻松设置/维护端口转发。

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

我在这里写了一篇带有代码示例的文章: .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play)

采纳答案by Frank Krueger

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

有一个很容易访问的 COM 库:

UPnP APIsPurpose

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.

UPnP API目的

UPnP?框架实现了智能电器、无线设备和PC的动态联网。有两个 API 可用于处理 UPnP 认证的设备:

控制点的API,它由一组用来寻找和控制装置COM接口。该设备主机API,它由一组用于实现由计算机主机设备的COM接口。

回答by Aaron Murgatroyd

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 CodePlex here:

我写了一个围绕微软 UPnP 控制点 COM 对象的完全托管的 UPnP 库,它提供完整的源代码和演示项目,您可以从 CodePlex 下载它:

http://managedupnp.codeplex.com/

http://managedupnp.codeplex.com/

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

它支持使用对象层次结构完全遍历 UPnP 描述文档,并且非常易于使用。

回答by denied66

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.

Mono.Nat 是一个非常好的 upnp 库,至少在我的情况下,到目前为止我遇到的问题比使用 NATUPnP 时少。

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

你可以在这里下载它,你可以在http://www.fluxbytes.com/csharp/upnp-port-forwarding-the-easy-way/找到一个关于如何操作它的不错的教程

回答by zezba9000

Was looking around for this stuff personally and found::

亲自四处寻找这些东西并发现:

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

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

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

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

回答by zezba9000

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.

此英特尔 UPnP 工具已作为开源工具重新发布,网址为:http: //opentools.homeip.net。这些新工具被称为“UPnP 技术的开发者工具”。它们是用 C# 构建的,但有一个免费的代码生成器可以输出 C 和 C# 堆栈。C 堆栈将在 Windows 和 Linux 上运行。

Ylian

伊莲

回答by cisv

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/

如果有人需要一个简单的库,我编写了使用 UPnPLib COM 组件的 ac# 类库。它具有打开和关闭端口的一些基本功能。我还没有在多个平台上测试过它,但它可以在 Windows 7 中的 Visual Studio 2010 上运行。请随时在http://sourceforge.net/projects/easyupnp/下载它

回答by Zer

For NAT specifically there is Mono.Nat.

对于 NAT,特别是 Mono.Nat。

回答by Walt D

I use this, which seems to work fine:

我使用这个,它似乎工作正常:

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

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

回答by Walt D

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

英特尔 UPNP 工具曾经能够在 C# 中导出 UPnP 客户端。该套件已弃用,但应该仍然有效。