Search code examples
c#.netwcf.net-core

System.ServiceModel not found in .NET Core project


I have a .NET Core xUnit project. I'm trying to call a WCF service from it but get the following exception:

System.InvalidOperationException occurred
  HResult=0x80131509
  Message=An error occurred while loading attribute 'ServiceContractAttribute' on type 'IMyContract'.  Please see InnerException for more details.

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

It works with a Framework 4.7 project with the same Nuget Package System.ServiceModel.Http.4.3.0.


Solution

  • Microsoft has made available the relevant assemblies as packages on NuGet now.

    System.ServiceModel.Primitives is the base package; add the others if necessary to your project.

    enter image description here

    Update (April 28th, 2022):

    WCF has been partially ported to .NET 5+ with an official library called CoreWCF: https://devblogs.microsoft.com/dotnet/corewcf-v1-released/