Add .NETFramework 4.5 dll to .NETCore project

I have a previously generated DLL with some corporate code that I would like to reuse in my .NETCore project. However, since the source DLL was created and compiled using .NETFramework 4.5, I cannot directly add the dll as a link.

I created a nuget package containing my dll, as shown here . After that I can add such a package to the project. However, I get the following error:

"MyAssembly.dll dependency does not support the .NETCoreApp framework, Version = v1.0"

I have already tried referencing .NETCore.Portable.Compatibility, but I don't think this is the right way. How can I use this dll for my code? This is what my project.json looks like after adding the Nuget package.

{ "version": "1.0.0-*", "dependencies": { "MyAssembly.dll": "1.0.0", "Microsoft.EntityFrameworkCore": "1.0.0", "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", "Microsoft.NETCore.Portable.Compatibility": "1.0.1", "NETStandard.Library": "1.6.0" }, "frameworks": { "netcoreapp1.0": { "imports": [ "dnxcore50", "portable-net451+win8" ] } } } 
+3
c # asp.net-core .net-core .net-framework-version
source share
2 answers

In the .netcore class library, you can add several frameworks in the json project file. By default, you will have a .net core framework. Just add a comma and add the required .net infrastructure.

 { "version": "1.0.0-*", "frameworks": { "netstandard1.6": { "dependencies": { "NETStandard.Library": "1.6.0" }, "imports": "dnxcore50" }, "net45": { "dependencies": {}, "imports": "net452" } } } 
+3
source share

If your .NET 4.5 library does not compile as PCL, you cannot reference it from a project that targets netcoreapp1.0. It must be recompiled as a portable library or target set of network standards.

0
source share

All Articles