Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I reference System.Net.Sockets in a Portable Class Library using Xamarin?

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.

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?

like image 862
BitBot Avatar asked Jun 04 '14 18:06

BitBot


1 Answers

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

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 automatically added to PCL

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.

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:

enter image description here

like image 115
Anders Gustafsson Avatar answered Oct 01 '22 01:10

Anders Gustafsson