简体   繁体   中英

Build a simple class library for ASP.NET Core and MVC 5 Applications

I want to build a simple C# Class Library that can be referenced from both ASP.NET Core 1.1 MVC and MVC 5 web applications. By simple I mean that the library just contains some enums and some string constants , ie no additional dependencies.

I have tried building the library as a .NET Core Class Library, but it seems this cannot be referenced by MVC 5 applications and vice versa. Currently, all components (class library and web applications) are running in the same solution.

Is there a way of achieving this?

Thanks.

You want a .NET Standard class library. Be sure to pick a version of the .NET standard that both .net core and full framework supports (1.5 works for 4.6.2 and net core)

See matrix in this article for full compatibilities:

blogs.msdn.microsoft.com - Introducing .NET Standard

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM