小编gok*_*tuk的帖子

DotNetOpenAuth.Asp无法在MVC4应用程序单元测试中加载程序集或其中一个依赖项

我在项目中面临非常奇怪的错误.我安装了DotnetOpenAuth.Aspnet和Microsoft.AspNet.WebPages.OAuth库nuget包.当我运行项目时没有问题.但是当我为控制器编写测试时,它会抛出如下的异常.

测试方法MvcApplication2.Tests.ControllerTest.should_return_not_empty_content引发异常:

    System.IO.FileLoadException: Could not load file or assembly 'DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' 
or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)

另一个奇怪的观点是,如果我在VS 2010中设置一个项目作为MVC3应用程序并且测试正在通过.没有失败.但是当我在VS2012中执行完全相同的设置时,它会触发与上面相同的错误.当我在stackoverflow上搜索时,我看到了这个解决方案, 但它也没有用.

您可以在以下行中找到所有项目和样本测试.它只是一个app app测试项目.很容易阅读.

此外,我在此处添加了一个示例代码,用于控制器和失败的测试.

代码预览的pastebin链接是http://pastebin.com/1PCpq3hW

任何帮助,将不胜感激.

Vs2010和2012失败和成功的项目

详细的日志结果如下


    *** Assembly Binder Log Entry  (13.12.2012 @ 22:27:31) ***

    The operation failed.
    Bind result: hr = 0x80131040. No description available.

    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Program Files (x86)\JetBrains\ReSharper\v7.0\Bin\JetBrains.ReSharper.TaskRunner.CLR4.exe
    --- A detailed …

visual-studio-2010 dotnetopenauth asp.net-mvc-3 asp.net-mvc-4 visual-studio-2012

10
推荐指数
3
解决办法
2万
查看次数