0
votes

So I have a .net core 3.1 project and a WCF in .net framework 4.7.2. I need to reference the .net core dll in the WCF project but I get this error:

Project targets 'netcoreapp3.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'.

I tried to add a .net standard project to communicate with both projects but I still get an error:

Project targets 'netcoreapp3.1'. It cannot be referenced by a project that targets '.NETStandard,Version=v2.0'.

What can I do to reference .net core dll in WCF .net framework?

2
You can't. If you want to use the library in .NET Old you need to target .NET Standard 2.0, not .NET Core. Not add another project in between but actually target .NET Standard 2.0 - Panagiotis Kanavos
.NET Core 3.1 is compatible with .NET Standard 2.1 which doesn't work with .NET Old. It contains and uses types that aren't available in .NET Old or .NET Standard 2.0 - Panagiotis Kanavos
@PanagiotisKanavos -I updated .net standart to 2.1, still doesn"t work - chana
The frameworks are not compatible. Could you explain why you are trying to do this? Then we could offer an alternative solution. - Shiraz Bhaiji
You need to target .NET Standard 2.0, not 2.1. 2.1 is only supported by. .NET Core 3.1 and up - Panagiotis Kanavos

2 Answers

2
votes

Based on your comment. You do not need to add references to the frameworks. Each layer is a seperate solution.

Business layer

  • .net core
  • talks to databace using EF Core
  • Offers a REST API using WEB API Core

Service layer

  • .net framework 4.7.2
  • Calls Business layer using a REST call
  • Offers a WCF Service

Note unless you have specific requirements that say you must offer a WCF layer, I would drop it. The WEB API on your business layer would be your service layer.

0
votes

There is no possibility to use .NET Core DLL in .NET Framework project - however, you can reference a .NET Standard 2.0 DLL in both .NET Core 3.1 and .NET Framework 4.7.2 projects.

You can also consider using gRPC for .NET instead of WCF. It is often recommended as WCF replacement. https://github.com/grpc/grpc-dotnet