Portable Library vs Library

The "Portable Library" project type in Xamarin Studio is presumably an equivalent of the Microsoft Portable Class Library (PCL).

For what reasons would you use a Portable Library rather than a plain old Library?

Specifically I am building for Android and iOS and I plan to have a common Library of pure .NET (data classes, some business logic, etc...) that I reference from my platform-specific projects. Would a PCL be a better choice?

Posts

  • MartinBauligMartinBaulig DEXamarin Team Xamurai

    A normal library is compiled against a specific version of the .NET Framework and references a specific version of mscorlib.dll and other base-class libraries both at compile and run-time. You can't share such a library between the mobile and desktop products because the corlib versions would be different.

    PCL solves this problem by remapping these base-class library references to the ones of the currently running application.

    In addition to that, PCL provides different "profiles" which allow you to select specific subsets of the .NET APIs.

  • RupertRawnsleyRupertRawnsley GBMember ✭✭✭

    @baulig Thanks for the quick and clear answer. It sounds like my common code needs to be in PCL then if I want to link it to platform specific projects.

    I'm much more comfortable extending abstract base classes in this way than I am with the more popular suggestions of linking source files or using compiler directives, both of which feel like a hack.

  • GuillermoGutierrezGuillermoGutierrez ESMember ✭✭✭

    Without PCLs you usually create a standard Library per platform and share the code using file links.

    This tutorial shows how to configure the Visual Studio for cross-platform development using Project Linker.

Sign In or Register to comment.