Ian Hebden
Ian Hebden

Reputation: 83

mvc 6 add class library

I am using VS2015 (RTM) and have a solution with two projects:

1) An MVC 6 ASP.NET Web Application

2) A Windows Split-View App (Universal Windows)

I would like to also add a class library to the solution that can be referenced by both of the projects, but can't find a way to do it.

If I add a Web Class Library (Package), I can reference it via the web application, but not by the Universal Windows App.

If I add a Windows Class Library (Universal Windows), I can reference it in the Universal Windows App, but when I try to add a reference to the MVC 6 Web Application I get a couple of thousand reference errors.

Is there an easy way to do this, i.e. share a class library between an MVC 6 app and a Universal Windows app, or is it a non-starter?

Upvotes: 3

Views: 473

Answers (1)

Jeffrey Chen
Jeffrey Chen

Reputation: 4680

The MVC 6 can’t reference the UWP class library since they are based on the different .NET runtime. MVC 6 is based on the .NET Core or Full .NET, the UWP is based on the .NET for UWP.

I did not have the MVC 6 installed in my machine to test. The portable library should work in this case, but I also failed to compile in MVC 5. As a workaround, you can considering using the code sharing between UWP project and MVC project.

Create a new folder named share_code in the solution folder, put the common code in this folder. In UWP project and MVC project, Add -> Existing Item, then you can re-use the code in both projects.

Upvotes: 1

Related Questions