微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 在PCL中使用System.Net.Sockets(.Net 4.5 phone 8)

我现有的.Net库已经可以用于.Net 4.5和 Windows Phone 8.
现在我想在一个可移植的类库中转换它,突然间我再也不能使用System.Net.sockets了.

我只打了.Net 4.5和Windows Phone 8.我没有选择XBox /商店app / silverlight.
Xamarin是自动选择的,因为它具有相同的要求.

我可以通过使用接口和东西来避免套接字,但是如果它们都支持它,为什么我不能使用它呢?

关于stackoverflow还有其他问题,但这些问题使用xBox或metro应用程序.

解决方法

似乎WinRT API已添加到PCL:

https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4443287-make-winrt-api-usable-in-portable-class-libraries

Make WinRT API usable in Portable Class Libraries targeting Windows 8 and WP8

That’s a great suggestion. We’ve added this capability for the new
versions of both platforms. So when you author a portable class
libraries with the following targets (or any subset) you’ll have
access to WinRT APIs as well:

  • Windows 8.1
  • Windows Phone 8.1
  • Windows Phone Silverlight 8.1 For the first two platforms,you’re also able to produce Windows Runtime components (WinMD).

Immo Landwerth
Program Manager
.NET Framework Team

您需要VS2013 Update 2.
这里有关于此更新的更多信息:
http://blogs.msdn.com/b/somasegar/archive/2014/04/02/visual-studio-2013-update-2-rc-universal-projects-for-windows-and-windows-phone.aspx

WinRT中的套接字位于Windows.Networking.sockets命名空间中:
http://msdn.microsoft.com/en-us/library/windows/apps/br226960.aspx

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐