Portable Class Library in .NET 4.0/4.5

Introduction

A few days back I was working on a Windows Phone application and as usual I created a class library project for keeping separate business logins. But I realize we cannot add as a reference a normal class library in the Windows Phone 7 Application.

Purpose

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 various types of projects more.

To install the Portable Class Library in your machine you can use Visual Studio 2010, save the download file (PortableLibraryTools.exe) on your computer, and run the installation program from a Command Prompt window. Include the /buildmachine switch on the command line.

The following assemblies are used for a Portable Class Library:

  • 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 following are the steps to create a Portable Class Library in Visual Studio 2011.

Step 1: Create a new project and choose Portable Class Library.

PrtCls1.png

Step 2:  Now go to project properties and select Library tab and click on the change button; you will see the Change Target Framework Dialog box; there you can select the framework for your library.

PrtCls2.png

Reference from

http://msdn.microsoft.com/en-us/library/gg597391.aspx

http://msdn.microsoft.com/en-us/library/gg597391%28v=vs.110%29.aspx

Up Next
    Ebook Download
    View all
    Learn
    View all