If you create a regular Class Library it has only one target Framework. it means you can only build an application with that to run in one platform, And if you would like to use this class library in other platforms such as mobile, azure and etc, you have to recompile it. Portable Class Library or PCL is a new project in Visual Studio from Microsoft that enables you to create C# and Visual Basic libraries that run on a variety of .NET platforms to write once and use more.
A portable class library is just a class library that can run on various .NET Framework platforms like Windows Phone, Silverlight, Xbox, and Windows Store apps. A portable class library is a DLL that can be shared with developers and has a common set of code that will work on various platforms. This really helps to reusability of your code.
If you have Visual Studio 2012 you or VS Service pack 1 you can get started to create a portable class library. As you can see in this picture, the Visual studio provides a project template for portable Class libraries:
After selecting the Portable Class Libraries, you'll see another template to choose the target API:
you can select the target framework and create your PCL project. if create the project, you'll see in references these default assemblies: mscorlib.dll, System.dll, System.Core.dll, System.Xml.dll, System.ComponentModel.Composition.dll, System.Net.dll, System.Runtime.Serialization.dll, System.ServiceModel.dll, System.Xml.Serialization.dll, System.Windows.dll (from Silverlight)
the portable class library supports for different platforms (see here for more information)
Portable class libraries are not something different, They are compiled just like other assemblies. You can build a library that is usable across all your projects but by using PCL You avoid having multiple copies of the code and several kinds of class libraries for different targets in your solution. It is so useful for library developers who make their assemblies to other developers(as a guidance or open source app) who build apps for different kinds of Microsoft platforms. You can easily Create a Portable Library project and reference it from any .NET Framework. Within a Portable Class Library project, you can specify which .NET platforms the library is intended to run on. for guys with eagle eyes which are thinking about MEF at the moment, I have to say that the MEF API is Not available for all platforms, for example, windows phone and Xbox 360 don't support for MEF, but you can use MEF in the portable class library.
Refer to these articles for more information:
- http://kishore1021.wordpress.com/2012/08/06/what-is-portable-class-library-project-in-visual-studio-2012-net-4-5/
- http://msdn.microsoft.com/en-us/library/gg597391(v=vs.110).aspx
- http://msdn.microsoft.com/en-us/magazine/hh852593.aspx