简体   繁体   English

为ASP.NET Core和MVC 5应用程序构建一个简单的类库

[英]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. 我想构建一个可以从ASP.NET Core 1.1 MVCMVC 5 Web应用程序引用的简单C#类库 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. 我曾尝试将该库构建为.NET Core类库,但是看来MVC 5应用程序无法引用该库,反之亦然。 Currently, all components (class library and web applications) are running in the same solution. 当前,所有组件(类库和Web应用程序)都在同一解决方案中运行。

Is there a way of achieving this? 有没有办法做到这一点?

Thanks. 谢谢。

You want a .NET Standard class library. 您需要一个.NET Standard类库。 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) 确保选择.net核心和完整框架都支持的.NET标准版本(1.5适用于4.6.2和net核心)

See matrix in this article for full compatibilities: 有关完整兼容性,请参见本文中的矩阵:

blogs.msdn.microsoft.com - Introducing .NET Standard blogs.msdn.microsoft.com-.NET标准简介

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 SQLite 数据库文件从 class 库添加到 ASP.NET 核心 MVC Z78E6221F6393D13566681DB 项目 build398814CE 目录 - Add SQLite dtabase file from a class library to ASP.NET Core MVC output directory on project build 使用 ASP.NET Core 1.1 (MVC) 访问类库中的 httpcontext - Accessing httpcontext in class library with ASP.NET Core 1.1 (MVC) ASP.NET Core DI在类库中? - ASP.NET Core DI in a class library? 引用ASP.NET Core类库 - Reference an ASP.NET Core Class Library ASP.NET MVC 5应用程序的构建速度很慢 - ASP.NET MVC 5 applications really slow to build ASP.NET Core 3.1 API 参考 a.Net Standard class 库 - 在 Azure DevOps 中构建失败 - ASP.NET Core 3.1 API referring to a .Net Standard class library - build failed in Azure DevOps 使用 Asp.Net 核心 Mvc 或 Razor Pages 构建的 Web 应用程序中是否使用了任务并行库、PLINQ 或并发集合? - Is Task parallel library, PLINQ or Concurrent Collections used in Web Applications built with Asp.Net core Mvc or Razor Pages? 在许多公司的asp.net mvc 3 Web应用程序上共享公用.net类库的一种容易维护的方法是什么? - What is an easily maintainable way to share a common .net class library over many corporate asp.net mvc 3 web applications? ASP.NET Core 2.1。 MVC视图中的Razor UI类库 - ASP.NET Core 2.1. Razor UI Class Library in MVC View 如何从我的ASP.NET Core MVC应用程序中的类库记录NLog调用? - How to log NLog calls from a class library in my ASP.NET Core MVC app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM