0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

How to use SharedProject with UWP application in Visual Studio

Last updated at Posted at 2019-01-17

Introduction

In Visual Studio we can create Shared Project and use it later in any UWP project. This is one of a good way we can re-use some C# codes in multiple UWP project.

What is Shared Project?

Shared Project is a great way of sharing common code across multiple applications. It will be added as part of the application and compiled along with it. So we can easily re-use the some identical C# code with multiple application. It can easily be done using the Add Reference feature in UWP application solution explorer.

Create a Shared Project

From Visual Studio Click File -> New Project Navigate to Template -> Visual C#
From there we will find "Shared Project" C# template
solution_explorer (3).png

Once we create a new project, It will create a Shared Project in the Solution Explorer like below
image60.png
After that we will add some code to the Shared Project we just create
image61.png
So we added class Student into it

Use Shared Project in UWP application

From the existing UWP project right click on the Solution Explorer -> Add -> Existing Project and then browse for the Shared Project that we just created.
solution_explorer.png
After that from the project reference tree right click on the Project Name -> Add -> Reference
solution_explorer (1).png
And from the Reference Manager Choose Shared Project and Check the Project we just created. If there is nothing there, we can go and browse for it.
solution_explorer (2).png
Now that our Shared Project code is ready to used.
From our MainPage.cs we import the Student class from the Shared Project
P.S: SharedProject is my shared project namespace. It may be vary.

using SharedProject;

namespace DemoUWP {
   public sealed partial class MainPage: Page {
      public MainPage() {
         Student student = new Student();
      }
   }
}

The code above is the demonstration of how we can use the code. That's all for this article. Thank you!

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?