简体   繁体   English

使用Coherence和Moq时的System.BadImageFormatException

[英]System.BadImageFormatException when using Coherence and Moq

When using the following line in a moq unit test, I get a System.BadImageFormatException. 在moq单元测试中使用以下行时,我得到一个System.BadImageFormatException。

mockDataAccessLayer.Setup(dal => dal.ListItems(It.IsAny<List<IFilter>>()));

The exception: 例外:

System.BadImageFormatException : [C:\Users\ric\AppData\Local\Temp\q3a2acu1.brz\RJ.DAL.test\assembly\dl3\cb8fb82f\e33b012a_c5f6cc01\RJ.DAL.test.DLL] The signature is incorrect.
at RJ.DAL.test.DALLayerTest.DataAccessLayerTest()

The full unit test: 完整单元测试:

[Test]
public void DataAccessLayerTest()
{   
    var mockDataAccessLayer = new Mock<IDAL>();
    mockDataAccessLayer.Setup(dal => dal.ListItems(It.IsAny<List<IFilter>>()));
    var dataAccessLayer = mockDataAccessLayer.Object;
}

I am fairly sure the problem lies with the List of IFilters, as I use very similar code elsewhere without the It.IsAny which works fine. 我很确定问题在于IFilter列表,因为我在其他地方使用非常相似的代码而没有It.IsAny工作正常。 Any ideas? 有任何想法吗?

As Hans mentioned, it was due to missing an assembly for the interface. 正如Hans所说,这是由于错过了接口的程序集。 Adding the dll containing the interface fixed the problem. 添加包含接口的DLL修复了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM