Using Shared Project across multiple applications in Visual Studio 2015

By | July 28, 2015

Shared Project is a great way of sharing common code across multiple application  We already have experienced with the Shared Project type in Visual Studio 2013 as part of Windows 8.1 Universal App Development, But with Visual Studio 2015, it is a Standalone New Project Template; and we can use it with other types of app like Console, Desktop, Phone, Store App etc.. This types of project is extremely helpful when we want to share a common code, logic as well as components across multiple applications with in single platform. This also allow to access the platform specific API’s , assets etc.

image

Let’s have a look how we can use the Shared Project Template with help of simple application and flow.

Check out all great features of Visual Studio 2015

Create The Shared Project

Run a New Instance of Visual Studio 2015 –> File –> New Project

Navigate to Templates –> Visual C# , there you will find “Shared Project” C# Template.

Creating a Shared Project

Creating a Shared Project

P.S : If you Search template with “Shared Project”, you would also see “Shared Project” of type VB and Java Script.

Once you create a new Project, it will create a Shared Project in Solution Explorer like below

First look of Shared Project

First look of Shared Project

Add a new class Student.

Adding a Simple Class in Shared Project

Adding a Simple Class in Shared Project

Your Shared Project is ready.

 

Using Shared Project – Console Application

Add a new Console Application in the Solution.  Add the SharedProject1 as Reference, from the References –> Shared Projects –> Solution

 

Using Shared Project in a Console Application

Using Shared Project in a Console Application

This will add the “SharedProject1” as reference to the Console Application Solution.

Using Shared Project in a Console Application

Using Shared Project in a Console Application

Now onwards, you can use it just like other application as application reference.

Using Shared Project in a Console Application

Using Shared Project in a Console Application

Using Shared Project in a Console Application

Using Shared Project in a Console Application

 

Using Shared Project – Windows Store App

Similar to Console Application, You can add the Shared Project for Windows Store App and can use it.

Using Shared Project in a Console Application

Using Shared Project in a Console Application

Using Shared Project – Windows Phone App

Create a new Windows Phone App, Added the Shared Project as Reference, and use it,

Using Shared Project in a Console Application

Using Shared Project in a Console Application

Incase of you are trying it with Existing Universal App, You should be able add this as reference as well

Using Shared Project in a Console Application

Using Shared Project in a Console Application

 

Similarly you can try this out for other application as well.  The example of Student class is very simple, but just think in terms of power of this project types when you have lot of shared code, business rules .

Hope this helps..

4 thoughts on “Using Shared Project across multiple applications in Visual Studio 2015

  1. Pingback: 10 New features of Visual Studio 2015 that you should know | Abhijit's World of .NET

  2. Magnus

    Isn’t just Shared project a class library? What differs?

  3. Pingback: Difference between Shared project and Class Library Project in Visual Studio 2015

Comments are closed.