简体   繁体   中英

Add a reference to .Net Core project from .Net Framework project

Note: I've seen the six similar questions and answers, but didn't work for me

I'm working on old.Net Framework 4.6.1 project. I need to use a library, that doesn't work under.Net Framework. It compiles, but simply doesn't work.

I thought of creating new.Net Core project, as I know that.Net Core works without problems with the library.

However, I didn't manage to let the.Net Framework project use the.Net Core library. Is it even possible? How can it be done? I've looked at other SO question&answers, but didn't manage to do so.

Linking.Net Standard library works, but in that case, the code in the.Net Standard still runs as.Net Framework, and thus doesn't work (as the library is broken with.Net Framework).

Check out the compatibility chart .

What you're running into is the second note in the fine print.

2 The versions listed here represent the rules that NuGet uses to determine whether a given .NET Standard library is applicable. While NuGet considers .NET Framework 4.6.1 as supporting .NET Standard 1.5 through 2.0, there are several issues with consuming .NET Standard libraries that were built for those versions from .NET Framework 4.6.1 projects. For .NET Framework projects that need to use such libraries, we recommend that you upgrade the project to target .NET Framework 4.7.2 or higher.

If the .NET Core project is 3.0 or higher, it's probably compatible with .NET Standard 2.1. .NET Framework is only compatible with .NET Standard up to 2.0.

In conclusion,

  • Your .NET Core project must be .NET Core 2.1 (lower versions are End-Of-Life, can use but not recommended)
  • Upgrade .NET Framework Target to 4.7.2

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