1

I have a bit of C# / .NET experience, but I am fairly new to using Portable Class Libraries (PCLs) and writing code for Xamarin.iOS

My general understanding is 'regular' DLL in Visual Studio it will depend on, say, .NET 4.x, which has plenty of native dependencies.

In contrast, so I thought, PCL profiles denote a (meta) subset of APIs provided by the platform, and PCLs target these profiles and will be totally platform independent.

What confuses me now is that a number of 'portable' libraries (Portable Compression for example but there are many more), also require native dependencies.

Doesn't this defeat the purpose of PCLs? If not, why are they called 'portable', and what is their difference to regular IL assemblies?

left4bread
  • 1,514
  • 2
  • 15
  • 25
  • Portable in this context always comes with a list of supported platforms. If the native part is available for all those platforms it will still hold for this context. It will certainly make it much harder to add additional platforms to the existing list though. – Lasse V. Karlsen Jan 19 '16 at 10:45

1 Answers1

1

What makes it "portable" is that you can use the package in different kind of projects and write the same code to use it. What is never portable is deployment, you use a very different way to get your program and its libraries deployed to, say, a phone vs a desktop machine.

Nuget packages like that always include a Powershell script that runs when you add the package. They look at your project to know what DLL needs to be copied. The package usually include them all but you'll use only one specific set of them. The one that can run on the specific device you selected. Which is for one why the blog post points out that you cannot target AnyCPU, the Powershell script needs to know whether to copy the 32-bit or the 64-bit version of the native DLL.

More details about this script and a way to get the DLLs deployed in this post.

Community
  • 1
  • 1
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thanks for the info. Just that I understand you correctly, you are saying this is a special property of these 'portable' libraries in particular. True PCL libraries should also be deployable to each platform as long as their referenced DLLs / classes can be resolved? – left4bread Jan 19 '16 at 12:29
  • Yes. "referenced DLLs" does not help you that much understanding this, references are a property of managed code. Different targets need different native code DLLs, it just take copying the right one. – Hans Passant Jan 19 '16 at 12:36