Reputation: 3799
I am developing a REST web server using .net. I need to call 3rd party assemblies that was compiled against .net framework v4.0. In VS 2017 I choose the "ASP .NET Core Web Application" (.NET Core 2.1) template for my project. I try to add the 3rd party assemblies by using Project: Add->Reference... However I get yellow warning sign icons on the assemblies in the Project:Assemblies tree view.The properties page for these assemblies are all blank.
Can .net core call .net 4 assemblies? If so how do I add them to the project correctly?
Upvotes: 2
Views: 3730
Reputation: 12171
.NET Core cannot reference assemblies targeted .NET Framework.
But you can create assembly (Class Library) targeted .NET Standard. This assembly can be referenced both from .NET Framework 4.x and .NET Core so, you can have shared functionality in assembly that can be referenced from both .NET Framework and .NET Core.
If .NET Standard is not the case referenced assembly should be targeted .NET Core.
See additional info here - .NET Standard
Upvotes: 4
Reputation: 6171
No. .NET core project cannot refer legacy .NET 4.x assemblies. So the library needs to be rebuilt to support .NETCore.
Recently Microsoft has released .NET Standard to build library for both platforms, however, the assemblies remain different. It's just compiled into different targets.
Upvotes: 2