Visual StudioSo you want to use the same code base and target different user experiences? For example, say you want to  use the same business logic to access data in Windows 8, Windows Phone, and your Silverlight or XBox applications. (Or maybe even Android and iPhone using Mono.) In the past, this has meant different libraries for each solution.

How about if you could put all the projects together in one solution and target each user experience?

You can use the new Portable Class Library (PCL) comes with .NET Framework 4.5. A separate project template is available on Visual Studio 2012. The portable class library can also be installed on top of Visual Studio 2010. It can be downloaded from here.

You can create one or more class libraries to hold the common business logic and share it across applications targeting different platforms like .Net Framework, Windows Phone, Windows 8 user style apps, Silverlight and Xbox.

Platform selection window

When you specify the platforms you want to target in a Portable Class Library project, the supported assemblies for those platforms are automatically referenced in your project. You do not have to add or remove assemblies. The referenced assemblies are automatically updated if you change the target platforms.

The following table shows which features are supported on the available platforms and versions.

 

Feature

.NET Framework

Metro style

Silverlight

Windows Phone

Xbox 360

Core

LINQ

IQueryable

Only 7.5

Dynamic keyword

Only 4.5

Managed Extensibility Framework (MEF)

Network Class Library (NCL)

Serialization

Windows Communication Foundation (WCF)

Model-View-View Model (MVVM)

Only 4.5

Data annotations

Only 4.0.3 and 4.5

XLINQ

Only 4.0.3 and 4.5

System.Numerics

For more information

Introduction to Portable Class Library in .NET Framework 4.5 on CodeGuru

Portable Class Library Overview on MSDN

Announcing Portable Library Tools CTP [Justin Van Patten]

Try out Visual Studio 2012.

 

Bruce D. Kyle
Technical Evangelist | Microsoft Corporation

image