加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 22:02:10 所属栏目:百科 来源:网络整理
导读:我现有的.Net库已经可以用于.Net 4.5和 Windows Phone 8. 现在我想在一个可移植的类库中转换它,突然间我再也不能使用System.Net.Sockets了. 我只打了.Net 4.5和Windows Phone 8.我没有选择Xbox /商店app / silverlight. Xamarin是自动选择的,因为它具有相同
我现有的.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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读