简体   繁体   English

在PCL中使用System.Net.Sockets(.Net 4.5 + phone 8)

[英]Use System.Net.Sockets in PCL (.Net 4.5 + phone 8)

I have existing .Net libraries which work already for .Net 4.5 and Windows Phone 8. Now I would like to convert this in a portable class library and suddenly I can't use System.Net.Sockets anymore. 我现有的.Net库已经可以用于.Net 4.5和Windows Phone 8.现在我想在便携式类库中转换它,突然间我再也不能使用System.Net.Sockets了。

I only cheched .Net 4.5 and windows phone 8. Xbox/store app/silverlight is not selected. 我只打了.Net 4.5和Windows Phone 8.我没有选择Xbox /商店app / silverlight。 Xamarin is automaticly selected because it has the same requirements. Xamarin是自动选择的,因为它具有相同的要求。

I can avoid sockets by using interfaces and stuff, but why can't I use it if they both support it? 我可以通过使用接口和东西来避免套接字,但是如果它们都支持它,为什么我不能使用它呢?

There are other questions on stackoverflow about this but these use xbox or metro apps. 关于stackoverflow还有其他问题,但这些问题使用xbox或metro应用程序。

It seems the WinRT API is added to PCL: 似乎WinRT API已添加到PCL:

https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4443287-make-winrt-api-usable-in-portable-class-libraries 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 使WinRT API可用于面向Windows 8和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: 因此,当您使用以下目标(或任何子集)创作可移植类库时,您也可以访问WinRT API:

  • Windows 8.1 Windows 8.1
  • Windows Phone 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). Windows Phone Silverlight 8.1对于前两个平台,您还可以生成Windows运行时组件(WinMD)。

Immo Landwerth Immo Landwerth
Program Manager 项目经理
.NET Framework Team .NET Framework团队

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM