[英]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,但只有WebProject
和ClassLibrary1Project
需要访问传统的.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.