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.
Let’s have a look how we can use the Shared Project Template with help of simple application and flow.
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.
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
Add a new class Student.
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
This will add the “SharedProject1” as reference to the Console Application Solution.
Now onwards, you can use it just like other application as application reference.
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 – Windows Phone App
Create a new Windows Phone App, Added the Shared Project as Reference, and use it,
Incase of you are trying it with Existing Universal App, You should be able add this as reference as well
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..