Question

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?

Was it helpful?

Solution

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

OTHER TIPS

Using advanced PCL development AKA "Bait and switch" you may be able to do this

see link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top