我有一本书.NET核心xUnit项目.我试图从中调用WCF服务,但出现以下异常:

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.

它使用带有相同Nuget包System.ServiceModel.Http.4.3.0的Framework4.7项目.

推荐答案

微软已经在NuGet now上以软件包的形式提供了相关的程序集.

System.ServiceModel.Primitives是基本包;如有必要,将其他项目添加到项目中.

enter image description here

.net相关问答推荐

.NET最小API BadRequest响应不返回正文

cmd 冻结中的 dotnet 命令.怎么了?

dotnet ef dbcontext scaffold command --data-annotations 或 -d 命令行参数似乎不起作用

在 C# 中,如何使用泛型的基类将泛型接口的所有实例注入到单个构造函数中?

当 Func 委托需要接口作为参数时,它是如何工作的?

无法实例化类的代理:System.Net.HttpWebRequest.找不到无参数构造函数

即时窗口中的动态导致Microsoft.CSharp.RuntimeBinder.Binder未定义或导入错误

lock() 是否保证按请求的顺序获得?

使用 Windows 服务和 C# 检测 USB 驱动器插入和移除

如何等到远程 .NET 调试器附加

如何从 .net 中的数组类型获取数组项类型

运算符重载 ==, !=, Equals

创建多个线程并等待所有线程完成

我不了解应用程序域

DataGridView 在我的两个屏幕之一上的可怕重绘性能

找不到库 hostpolicy.dll

如何将 VB 项目转换为 C# 项目

序列化一个可为空的 int

通过反射获取公共静态字段的值

C#/.NET 中仅命名空间的类可见性?