我有一本书.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相关问答推荐

在PowerShell中,XML子对象和属性是对象属性.它怎麽工作?

有没有更好的方法使用 Pusher Channels 的批事件发布消息?

如何正确使用await using语法?

Gacutil.exe 成功添加程序集,但在资源管理器中无法查看程序集.为什么?

将 int 转换为 .NET 中的位数组

为什么循环引用被认为是有害的?

如何在 EF 代码优先中禁用链接表的级联删除?

使用返回随机结果的函数进行单元测试

Winforms:Application.Exit vs Environment.Exit vs Form.Close

在 C# 中与块等效?

所有数组在 C# 中都实现了哪些接口?

自定义属性的构造函数何时运行?

在生产环境中部署调试符号(pdb 文件)有什么风险?

文件按文件名模式存在

是否可以完全用托管的 .NET 语言编写 JIT 编译器(本地代码)

说明 C# 中 volatile 关键字的用法

IronPython 与 Python .NET

System.IO.IOException:使用 System.IO.Path.GetTempFileName() 时文件存在 - 解决方案?

.NET 中的 java.lang.IllegalStateException?

在 C#/.NET 中合并两个图像