神秘的"Couldn't not load file or assembly 'System.ServiceModel, Version=4.0.0.0..."错误



方案:我有一个WCF终结点(终结点制造(,它将另一个WCF终结点(终结点DataAPIClient(连接为ConnectedService。 A 中实体的构造函数实例化"客户端"(见下文(。 最重要的是,我有一个xUnit测试项目测试A。

// Manufacturing constructor
public Manufacturing() {
client = new DataAPIClient();
}

在 xUnit 项目中实例化 制造端点 = 新制造((;

问题:当测试项目尝试实例化制造时,发生了一些变化(我不知道是什么(。 我收到此错误:

Message: System.IO.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.

我已经在两个端点中验证了System.ServiceModel.dll。 DataAPIClient 有 4.0.30319,制造业有 4.0.0.0。

附言 我确实更改了制造项目的名称...不确定这是否导致了这种情况,但我认为这可能值得一提。

任何帮助都非常感谢...我一直在谷歌上搜索,但一无所获。

根据Howcheng的建议,我注意到由于我使用的是xUnit Test Project(.NET Core(,我无法(或者我只是不知道如何(添加对System.ServiceModel.dll的任何引用。 因此,我创建了一个单元测试项目(.NET Framework(并添加了xUnit Nugets和System.ServiceModel.dll程序集。 错误消失了。

相关内容

最新更新