从控制台应用程序引用PCL的依赖项

时间:2016-12-05 23:54:08

标签: c# .net udp portable-class-library lifx

我正试图通过局域网与一些LIFX灯泡进行通信。

他们使用自己的协议,而不是重新发明轮子,我决定利用LIFX.Lib。这似乎是最完整的选择。

问题是,它是一个PCL库,我在引用适当的类型来调用方法时遇到了问题。

examples依赖于DatagramSocket,它似乎是Windows.Networking.Sockets命名空间的一部分。据我所知,这是一个“通用应用程序” - 只是框架的一部分。我找不到任何方法从我的控制台应用程序引用它。我在网上找到的少数文件声称它不需要特定的参考,而且是核心框架的一部分。

我尝试启动通用类库,但后来无法加载nuget包(没有支持的目标)

我的印象是PCL只能包含对所有支持平台上可用库的引用,所以我对它为什么不起作用感到有些困惑。

我是否误解了PCL是如何工作的,还是有一种明显的方法可以解决这个问题?如果不这样,是否有人知道另一个具有类似功能的库?

编辑:道歉,我应该提一下:

.Net 4.6.1 / C#/ VS2015 Update 3 / Win 10

1 个答案:

答案 0 :(得分:1)

The example in the README page is UWP specific, but the library itself should be applicable to your .NET Framework application.

The PCL profile is 151, which means the library can target .NET Framework 4.5.1 and higher, Windows Phone (non-Silverlight) 8.1, Windows 8.1, UWP and Xamarin applications.

If you are developing for .NET Framework, you should be able to use the Socket class or corresponding together with LIFX.Lib. Also note that the repository includes a console application which should be .NET Framework specific. This sample should give you further details on how to use LIFX.Lib in .NET Framework.