【发布时间】:2017-08-07 10:43:36
【问题描述】:
我有一个 .NET Core 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 的 Framework 4.7 项目。
【问题讨论】:
-
@silkfire 我担心这一点。这在任何地方都有记录吗?我可以在不同的框架中安装相同的包并获得不同的功能集,这太疯狂了。
-
@silkfire 如果这是答案,请随意放下它。
-
请参阅Microsoft's .NET API Reference 网站,了解 .NET Core 支持的内容以及仅限 .NET Framework 的内容
-
@BanksySan 显然,关于它已从主框架本身中删除的事实,我似乎是正确的;考虑到这一点,很遗憾我说没有解决方案,而事实上微软已经在 NuGet 上提供了相关程序集作为可选包。随意将我接受的答案更改为以下投票最多的答案。
-
或者只是在终端窗口中运行它(dotnet add package System.ServiceModel.Primitives)