Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 883
BanksySan Avatar asked Aug 07 '17 10:08

BanksySan


People also ask

How do I install system ServiceModel?

ServiceModel. Select Project-> Add Reference and then select the assembly name. Thank you for your answer!

Where do I put system ServiceModel in web config?

servicemodel element in the web. config file. Under the first level of the system. servicemodel element, there are behaviors, bindings and services.

What is ServiceModel?

BasicHttpBinding Class (System.ServiceModel) Represents a binding that a Windows Communication Foundation (WCF) service can use to configure and expose endpoints that are able to communicate with ASMX-based Web services and clients and other services that conform to the WS-I Basic Profile 1.1.

Can we use WCF in .NET Core?

NET Core and . NET 5 support calling WCF services, but won't offer server-side support for hosting WCF. There are two recommended paths for modernizing WCF apps: gRPC is built on modern technologies and has emerged as the most popular choice across the developer community for RPC apps.


1 Answers

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

like image 106
silkfire Avatar answered Oct 06 '22 20:10

silkfire