简体   繁体   中英

Referencing Traditional .NET Framework from .NET Core

We have some .NET 4.x code we need to reference from our .NET Core website. I'm able to run .NET Core on Traditional .NET as described here by Cesar de la Torre .

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.

QUESTION: How can I ensure that only certain .NET Core assemblies have access to .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. The only references are between WebProject and the class library projects.

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.

Make sure to use high enough version of net , so that you can reference the netstandard you used.

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