简体   繁体   English

从.NET Core引用传统.NET Framework

[英]Referencing Traditional .NET Framework from .NET Core

We have some .NET 4.x code we need to reference from our .NET Core website. 我们需要从.NET Core网站引用一些.NET 4.x代码。 I'm able to run .NET Core on Traditional .NET as described here by Cesar de la Torre . 我可以在Cesar de la Torre这里描述的传统.NET上运行.NET Core。

PROBLEM: In order to compile, it appears I need configure all project.json files in a way that all assemblies have access to the Traditional .NET framework. 问题:为了编译,似乎我需要以所有程序集都可以访问Traditional .NET框架的方式配置所有project.json文件。

QUESTION: How can I ensure that only certain .NET Core assemblies have access to .NET 4.x? 问题:如何确保只有某些.NET Core程序集可以访问.NET 4.x?

I would like my solution to look like this: 我希望我的解决方案看起来像这样:

\WebProject <-- Requires .NET 4.x because of reference to ClassLibrary1Project
\ClassLibrary1Project <-- Requires .NET 4.x
\ClassLibrary2Project <-- Prevent .NET 4.x access 
\ClassLibrary3Project <-- Prevent .NET 4.x access

All the projects are .NET Core, but only WebProject & ClassLibrary1Project require access to the traditional .NET Framework. 所有项目都是.NET Core,但只有WebProjectClassLibrary1Project需要访问传统的.NET Framework。 The only references are between WebProject and the class library projects. 唯一的引用是WebProject和类库项目之间。

Thank you! 谢谢!

You should be able to do this by using netstandard1.x in the frameworks section in project.json for libraries that shouldn't have access to .Net 4.x and using net4xx for libraries that should. 您应该能够通过在project.json的frameworks部分中使用netstandard1.x来执行此操作,以netstandard1.x无法访问.Net 4.x并使用net4xx的库。

Make sure to use high enough version of net , so that you can reference the netstandard you used. 确保使用的足够高版本的net ,这样就可以参考netstandard你使用。

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

相关问题 从.NET Framework传统项目引用.NET Standard csproj项目 - Referencing .NET Standard csproj project from .NET Framework traditional project 从 .Net Core 3 引用 .NET Framework DLL - Referencing .NET Framework DLL from .Net Core 3 可以从 .net 核心应用程序引用“传统”(旧).net 库 - Possibility to reference "traditional" (old) .net libraries from .net core applications 从 Model .net 核心引用 ApplicationUser - Referencing ApplicationUser from Model .net core 将OwinADAuthentication从.NET Framework转换为.NET Core - Convert OwinADAuthentication from .NET Framework to .NET Core 从类库(.NET Core)引用ASP.NET Core Web应用程序(.NET Core) - Referencing ASP.NET Core Web Application(.NET Core) from Class Library (.NET Core) 面向.NET Core时引用旧的(完整的.NET Framework)类库 - Referencing old (full .NET Framework) Class Library when targeting .NET Core Docker - 构建 .net 核心可运行项目,引用 .net 框架 4.7.2 项目 - Docker - build .net core runnable project referencing .net framework 4.7.2 projects 在.net Core中引用.net 4.6.1库 - Referencing .net 4.6.1 Library in .net Core 在.NET Framework中引用库而不是.NET Standard中的库 - Referencing libraries in .NET Framework not in .NET Standard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM