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

查看:71
本文介绍了为什么我不能使用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 Framework(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 本身确实支持某些

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配置文件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天全站免登陆