为什么我不能使用 Xamarin 在便携式类库中引用 System.Net.Sockets? [英] Why can't I reference System.Net.Sockets in a Portable Class Library using Xamarin?

查看:24
本文介绍了为什么我不能使用 Xamarin 在便携式类库中引用 System.Net.Sockets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在可移植类库中使用 System.Net.Sockets API,以便我的项目可以重用套接字连接的代码.但是我无法在我的代码中引用该命名空间.

I am trying to use System.Net.Sockets API in a portable class library so that my projects can reuse code for socket connections. But I cannot reference that namespace in my code.

据我所知,PCL 将您限制为可在所有目标平台上使用的程序集.但我的目标是 ios、Android 和 .Net 4.5(使用 Xamarin),所有这些都应该有包含 API 的 system.dll 程序集.我错过了什么?

As I understand it, PCLs limit you to assemblies that are available on all targeted platforms. But I am targeting ios, Android, and .Net 4.5 (using Xamarin), and all of these should have the system.dll assembly that contains the API. What am I missing?

推荐答案

就目前而言,没有仅针对 PCL 配置文件

As it is right now, there is no PCL profile targeting only

  • .NET 框架 (4/4.03/4.5/4.5.1)
  • Xamarin.Android
  • Xamarin.iOS

例如,如果您尝试定义仅包含这些目标的可移植类库,项目 PCL 配置文件将自动添加 Silverlight 5 目标:

If you for example attempt to define a Portable Class Library with only these targets, the project PCL profile will automatically add the Silverlight 5 target:

尽管 Silverlight 5 本身确实支持某些 System.Net.Sockets 命名空间类型,这些类型都没有转移到任何 PCL 配置文件.据我所知,PCL System.Net 功能仅限于 HTTP 网络.

Even though Silverlight 5 itself does support some of the System.Net.Sockets namespace types, none of these types have been transferred to any PCL profile. As far as I can tell, the PCL System.Net functionality is limited to HTTP networking.

例如,如果选择.NET Framework 4.5,则对应PCL profile 24,System.Net.dll内容如下:

For example, if .NET Framework 4.5 is selected, this will correspond to PCL profile 24, for which the System.Net.dll contents are as follows:

这篇关于为什么我不能使用 Xamarin 在便携式类库中引用 System.Net.Sockets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆