System.ServiceModel not found in .NET Core project

Solution 1:

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

Solution 2:

If you are using .NET Standard 2.0 (that's what I tested with), you can install compatible NuGet packages.

The basic service model is available in System.ServiceModel.Primitives (currently v4.4.0).

If required, install System.ServiceModel.Http as well.

Solution 3:

The Microsoft WCF Web Service Reference Provider wraps SvcUtil.exe and will generate a .NET Standard project from your endpoint. Look in the project file and you'll see the ServiceModel references that will work for you.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.ServiceModel.Duplex" Version="4.3.0" />
    <PackageReference Include="System.ServiceModel.Http" Version="4.3.0" />
    <PackageReference Include="System.ServiceModel.NetTcp" Version="4.3.0" />
    <PackageReference Include="System.ServiceModel.Security" Version="4.3.0" />
    <PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
  </ItemGroup>
</Project>

When I needed to do this I was able to use the generated class library in my .NET Core project.