I have a .NET Core 2.1 app, a .NET MVC website (4.7.2) and I also have a .NET 4.7.2 class library.
What I'm trying to do is have my core 2.1 project reference the class library.
Now I've added the reference to the core project with no issues (it builds), but when I try to add the namespace to a class It doesn't come up.
I want both the app and the MVC site to share the same class library.
Here's the screen shot:
There should be another namespace, one called models
Any help would be great. Thanks
If you want to use full . NET Framework libraries, you can only target . NET Framework, unless you use multi-targeting and provide alternate implementations of those libraries for the . Net Core targets.
Add Class Library Reference To use a class library in your application, you must add a reference to the library to access its functionality. Right click on the project name of your console app in Solution Explorer and select Add ->Reference option.
You can reference .NET Standard
library instead. So you need to create .NET Standard
library with common shared logic and reference it from both - .NET Core
and .NET Framework ("full")
projects.
Note that while you may be able to use .NET Standard
without PackageReference
, it's recommended to do it this way. Find more details in Referencing .NET Standard Assemblies from both .NET Core and .NET Framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With