What is a Portable Class Library?
Asked Answered
I

4

112

On MSDN I noticed a section about a Portable Class Library, under Version Information.

See System.Object for an example. http://msdn.microsoft.com/en-us/library/system.object.aspx

I did a brief Google search and couldn't find anything about the Portable Class Library. Does anyone here know what it is or where I could find more information about it?

Ingres answered 8/3, 2011 at 22:9 Comment(1)
As a heads up - we added additional Portable Class Library support in Visual Studio 11 Beta that comes next week.Irinairis
P
85

UPDATE Oct 9 2017: Article comparing/constrasting .NET Core/Std/PCL UPDATE Nov 23 2016: Article by Rick Strahl

UPDATE Oct 29 2016: .NETStandard 1->2 FAQ UPDATE Oct 19 2016: This is the best interview/video I've seen to date covering .NET Standard 2.0

UPDATE Sep 27 2016: .NET Standard 2.0 announcement post has more good info

UPDATE Jun 6 2016: This article explains well how the .NETStandard library mechanism supersedes much of PCL

UPDATE Jul 10 2013: Excellent state of the PCL union summary blogpost from @shanselman with lots of concrete examples, screenshots and links. Puts any other answer here in the shade.

UPDATE May 20 2013:

UPDATE Apr 19 2013: Excellent dense summary of how it all hangs together from Intellisense through to run time in a blog post by Simon Cooper


Video: Channel 9 Visual Studio Toolbox show episode 14 June 2012

Video: Channel 9 Going Deep Show episode 27 Sep 2011


UPDATE Sep 11 2012: Good high level blog post with pictures, diagrams and motivating examples showing how MVVM Light and RX use it

UPDATE Apr 11 2012: Very good end to end piece by Scott Hanselman that gets to the point in dev speak very quickly including screenshots here (also contains very insightful 'how to think of it' information and links to samples). Also includes a resources section at the end that pretty much duplicates this entire post :D

UPDATE Jul 9 2012: This blog series by Mircea Trofin of the dev team (one part so far) is the most complete coverage yet, including screenshots and detailed matrices showing available features across your selections if you're into that sort of thing.


See Portable Library Tools anouncement blog post, which starts:-

The Portable Library Tools CTP adds a new "Portable Class Library" project template to Visual Studio that can be used to create class libraries in C# and VB that run on the various .NET platforms without recompiling.

It's used for creating a Class Library that targets multiple platforms (esp Silverlight variants such as WP7 and SL4, but including XNA on Xbox) at one time.

See also this InfoQ summary article

See also this release notice.

For down and dirty details, see Multi-Targeting Guidelines for Tools for Managed Code

Pelton answered 8/3, 2011 at 22:9 Comment(5)
@Marc Gravell: Doesnt happen often, phew! - but you did beat @Darin if that's any help...Pelton
Lots of great details, but I think this could benefit from a simple explanation for someone who's completely new to this.Brogle
@Brogle Well my attempts to keep it up to date have made it community wiki, so feel free to edit in anything you feel will explain it in the manner you feel helpful (I found the InfoQ article good), thought the ones at the top are probably the most well-roundedPelton
It would be better to summarize those articles and put a brief here. Currently, read by 40,450 people, with average 20 minute (let's assume) to go through the links, means 561 days wasted in total.Humpy
@Humpy Thanks for the assignment and sorry for disappointing you. Seriously though, it's a community wiki article as a result of my continual adding of articles. So, knock yourself out; I'm happy for it to be edited, or for you to add your own answer. Please note that the response below the line (which was written in 2011) remains within your brief. However, the TL;DR is that the present time the answer is to read the top article unless you're interested in the history.Pelton
R
53
  • The Portable Class Library project enables you to write and build managed assemblies that work on more than one .NET Framework platform. You can create classes that contain code you wish to share across many projects, such as shared business logic, and then reference those classes from different types of projects.

  • Portable Library Tools is a new Visual Studio add-in from Microsoft that enables you to create C# and Visual Basic libraries that run on a variety of .NET-based platforms without recompilation.

MSDN now has a nice article/documentation on it. You can check it out and see what is supported in Portable Class Library Icon For Portable Class Library.


The following assemblies are available within a Portable Class Library project:

  • 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)

You can find which members are supported by the Portable Class Library project in the reference topics for the .NET Framework Class Library. In the members table for a class, the following Portable Class Library icon appears next to supported members.

Icon for Portable Class library (Icon for the Portable Class Library which you will see in MSDN Docs.)


To create a Portable Class Library Project you need to have :

1. Visual Studio 2010 Service Pack 1 (SP1) (795KB Installer, 1.48GB ISO)

2. Portable Library Tools CTP (1.38MB)

After Installing Above updates you will get a new Project Template for Portable Class Library :

enter image description here

(Above Contents taken from MSDN)

UPDATE 2014:

Class Library Portable is part of Visual Studio 2014.

Randall answered 14/3, 2011 at 9:34 Comment(1)
Regarding the latest update, I don't think there is a Visual Studio 2014, but PCL seems to be included in Visual Studio 2013. (At least the community edition I have)Chelyabinsk
C
7

It's a class library that can run on various platforms.

Cascio answered 8/3, 2011 at 22:12 Comment(2)
Can i send my portable .csproj across to people who do not have these tools installed?Metabolite
To run a Portable Class Library application, an update for the .NET Framework 4 must be installed on your machine. This update is automatically installed with Visual Studio 2010 SP1, so you can run the Portable Class Library application without further modification on the computer that you used to develop the application. To run the application on a different computer, you can install the update manually.Growing
B
2

I found Documents a bit hard to understand so i tried to make things a little clear here.

Portable Class library is built to let programmers create projects that will run over multiple platforms like Xbox 360, Windows Phone, Silverlight and .NET Framework (4 and above). this is done through omitting some specific API's that is not supported by your chosen target platforms that will cause you to lose some available features of .Net Framework.

So we can say, choosing between Portable class library and Normal class library depends on target platforms of your project. if you want your app to work on Xbox and Desktop Computers with windows operating system, you better save your time and use PCL, other than that Normal class library will do fine.

for more information visit documentation page.

Now there is a new and open source technology called .Net Standard which will displace PCL. .NET Standard solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services:

  • .NET Standard is a set of APIs that all .NET platforms have to implement. This unifies the .NET platforms and prevents future fragmentation.
  • .NET Standard 2.0 will be implemented by .NET Framework, .NET Core, and Xamarin. For .NET Core, this will add many of the existing APIs that have been requested.
  • .NET Standard 2.0 includes a compatibility shim for .NET Framework binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
  • .NET Standard will replace Portable Class Libraries (PCLs) as the tooling story for building multi-platform .NET libraries.

You can see the .NET Standard API definition in the dotnet/standard repo on GitHub.

Reference

Bichromate answered 7/3, 2017 at 20:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.