TheRealVira
TheRealVira

Reputation: 1614

Reference a .NET Core 3.0 library in .NET 4.8?

I have been trying to follow some already existing tutorials and stackoverflow questions/answers, but nothing seems to be working;

I am working in Visual Studio 2019 V16.0.0 Preview 2.2, if that is relevant.

Upvotes: 6

Views: 4347

Answers (1)

Jose Perez Rodriguez
Jose Perez Rodriguez

Reputation: 266

As mentioned by Marc Gravell, .NET Core and .NET Framework are different frameworks. The Api Surface that each of them offer is different. A good way to picture their surface area is by using a Venn Diagram, where the intersection of both is what we call .NET Standard. If the library you are consuming was targeting .NET Standard, then this would be guaranteed to work in both .NET Framework 4.8 and in .NET Core 2.1+. You can try consuming a .NET Core 3.0 library in a .NET Framework app but that is not guaranteed to work, as you might get lucky and your .NET Core library only needs the API surface that they have in common, but most likely it will need something that is only supported in .NET Core 3.0 which will mean that you will get Runtime Exceptions for methods not found, types not found, or assembly load issues.

Do you own the .NET Core Library code? If so, the best option for you would be to try to retarget to .NET Standard (so that you can use the library in the future in other frameworks) or .NET Framework directly, and that way you would know that all of the API surface your library needs will be present at runtime.

I hope this helps clarifying the issue, but feel free to reply in case you want more details.

Upvotes: 1

Related Questions