In a Visual Studio solution, I need to have a desktop winforms application project (.Net framework 4.0) depending on a .Net Core library project. I can't migrate the application to .Net core yet, but I need functionalities from .Net core (ie Microsoft.EntityFrameworkCore). That's why I created a new project as a dependency.
It seems to cause a problem at build time:
Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found
Idem with DateTime, Enum, Decimal, ...
As if object wasn't the same in both project. I tried to use Microsoft.Windows.Compatibility but it doesn't seem to be a solution.
Is there a way to have both projects build and run together?
EDIT 1
I tried with a .Net standard project instead of .Net core, but in this case I can't even add a reference from .Net framework app to .Net standard library.
Project "Std.csproj" targets "netstandard2.0", it can't be referenced by a project that targets ".NetFramework,Version=v4.0"
EDIT 2
I still get the same error with my dependency in .Net core 2.0 and my app in .Net Framework 4.6:
Project "Std.csproj" targets "netstandard2.0", it can't be referenced by a project that targets ".NetFramework,Version=v4.6"
EDIT 3
I finally got rid of the error with .Net Framework 4.6.1. But, according to required configuration for this framework, it means I can't deploy to Windows XP anymore. To study...
As my goal is to migrate gradually to .Net Core, any advice is welcome.




.NET 4.0is unsupported for many years now. It never got any kind of .NET Standard support - it can't, as it doesn't even supportasync/await. You need to upgrade to .NET 4.6.1, preferably .NET 4.7.2 to avoid problems with compatibility libraries.