我怎么拉DotNetOpenAuth集的引用到单元测试项目为ASP.NET MVC4解决方案? [英] How do I pull DotNetOpenAuth assembly references into unit test project for ASP.NET MVC4 solution?

查看:528
本文介绍了我怎么拉DotNetOpenAuth集的引用到单元测试项目为ASP.NET MVC4解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

铊;博士版本:我坚持了异常: System.IO.FileLoadException:无法加载文件或程序集DotNetOpenAuth.AspNet,第4版。 0 .0.0 ...

Tl;dr version: I am stuck with the exception: System.IO.FileLoadException : Could not load file or assembly 'DotNetOpenAuth.AspNet, Version 4.0.0.0 ...

一个有点遗憾的是MSFT新MVC4项目模板使用,因此许多静态类和方法的权威性。要包装所有会员/ AUTH功能合并到实现一个接口,这样我可以模拟单元测试的类。

A bit dismayed that msft used so many static classes and methods for auth in the new MVC4 project template. Want to wrap all membership/auth functionality into a class that implements an interface so that I can mock for unit tests.

一对夫妇挣扎的夜晚之后,我决定从头开始,所以我删除了所有DotNetOpenAuth *装配引用和的NuGet package.config引用。我都引用同样拆下来Micrsoft.Aspnet.WebPages.OAuth.dll。

After a couple of evenings of struggling, I have decided to start from scratch, so I removed all DotNetOpenAuth* assembly references and nuget package.config references. I have similarly removed all references to Micrsoft.Aspnet.WebPages.OAuth.dll.

重新安装包:我跑的安装包dotnetopenauth.aspnet 的针对解决方案三个项目在需要对DLL引用

Reinstalling packages: I run install-package dotnetopenauth.aspnet against three projects in solution which need the dll references.

解决方案将不建,因为我的包装都有它包装的方法:Microsoft.AspNet.WebPages.OAuth文件(.dll).OAuthWebSecurity.RegisteredClientData,因此我需要这个总成的引用,所以我跑的请在安装包microsoft.aspnet.webpages.oauth 的针对相同的三个项目。

Solution will not build, as my wrapper has a method which wraps: Microsoft.AspNet.WebPages.OAuth(.dll).OAuthWebSecurity.RegisteredClientData and therefore I need a reference to this assy, so I run install-package microsoft.aspnet.webpages.oauth against the same three projects.

解决方案建立,但是当我运行单元测试参考Microsoft.AspNet.WebPages.OAuth文件(.dll).OAuthWebSecurity.RegisteredClientData我得到一个运行时异常: System.IO.FileLoadException:无法加载文件或程序DotNetOpenAuth.AspNet,第4版。 0 .0.0 ...

Solution builds, but when I run the unit test referencing Microsoft.AspNet.WebPages.OAuth(.dll).OAuthWebSecurity.RegisteredClientData I get a runtime exception: System.IO.FileLoadException : Could not load file or assembly 'DotNetOpenAuth.AspNet, Version 4.0.0.0 ...

在所有三个项目,以本次大会的引用参考文献4 1 .0.0一样,在DotNetOpenAuth.AspNet assemblyIdentity在我的web.config。

The references to this assembly in all three projects reference 4.1.0.0, as does the DotNetOpenAuth.AspNet assemblyIdentity in my web.config.

我使用ReSharper的运行测试,并且测试NUnit的风格。

I'm using resharper to run the test, and the tests are nunit style.

和终于在这里是什么我fuslogvw看到糊状。显然,事情正在寻找4. 0 .0.0但我想不出什么或做这件事(我有几次删除这个转储引用的临时数据文件夹):

And finally here is a paste of what I see in fuslogvw. Obviously something is looking for 4.0.0.0 but I can't figure out what or what to do about it (I have a couple of times deleted the temp data folder referenced in this dump):

的**的 * 的**的 大会粘结剂日志条目(2012年11月13日@下午10时04分54秒) 的**的 * 的**的 * 的**的 * 的**的 *

***** Assembly Binder Log Entry (11/13/2012 @ 10:04:54 PM) ************

操作失败。
绑定结果:HR = 0x80131040。没有可用的描述。

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

这是载入大会经理\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ clr.dll
根据运行可执行C:\\ Program Files文件(x86)的\\ JetBrains的\\ ReSharper的\\ 7.0 \\ BIN \\ JetBrains.ReSharper.TaskRunner.CLR4.MSIL.exe
---详细的错误日志如下。

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

=== pre-绑定状态信息===
日志:用户= I7 \\戴夫
日志:显示名称= DotNetOpenAuth.AspNet,版本= 4.0.0.0,文化=中性公钥= 2780ccd10d57b246
 (完全指定)
日志:应用平台=文件:/// C:/SVN/trunk/SoAndSo45/SoAndSo.Com.Tests.Unit/bin/Debug
LOG:初始PrivatePath = NULL
日志:动态基= NULL
日志:缓存基= C:\\用户\\戴夫\\应用程序数据\\本地的\\ Temp \\ kpsvgxtp.io4
LOG:AppName的= SoAndSo.Com.Tests.Unit

=== Pre-bind state information === LOG: User = i7\dave LOG: DisplayName = DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246 (Fully-specified) LOG: Appbase = file:///C:/SVN/trunk/SoAndSo45/SoAndSo.Com.Tests.Unit/bin/Debug LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = C:\Users\dave\AppData\Local\Temp\kpsvgxtp.io4 LOG: AppName = SoAndSo.Com.Tests.Unit

日志:此绑定的默认加载上下文开始。
日志:未找到应用程序配置文件。
日志:使用主机配置文件:
日志:从C使用计算机配置文件:\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ CONFIG \\ machine.config中。
日志:后政策参考:DotNetOpenAuth.AspNet,版本= 4.0.0.0,文化=中性公钥= 2780ccd10d57b246
日志:GAC查找不成功。
日志:新的URL文件试图下载:/// C:/SVN/trunk/SoAndSo45/SoAndSo.Com.Tests.Unit/bin/Debug/DotNetOpenAuth.AspNet.DLL。
日志:程序集下载成功。文件试图设置:C:\\ SVN \\干线\\ SoAndSo45 \\ SoAndSo.Com.Tests.Unit \\ BIN \\调试\\ DotNetOpenAuth.AspNet.dll
日志:进入下载缓存安装阶段。
日志:大会名称为:DotNetOpenAuth.AspNet,版本4.1.0.0 =文化=中性公钥= 2780ccd10d57b246
警告:比较程序集名称时发生不匹配:次版本
错误:程序集引用不匹配发现大会的定义。
错误:安装程序失败,HR = 0x80131040。
错误:未能完成组装(HR = 0x80131040)的设置。探测终止。

LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: DotNetOpenAuth.AspNet, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246 LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/SVN/trunk/SoAndSo45/SoAndSo.Com.Tests.Unit/bin/Debug/DotNetOpenAuth.AspNet.DLL. LOG: Assembly download was successful. Attempting setup of file: C:\SVN\trunk\SoAndSo45\SoAndSo.Com.Tests.Unit\bin\Debug\DotNetOpenAuth.AspNet.dll LOG: Entering download cache setup phase. LOG: Assembly Name is: DotNetOpenAuth.AspNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246 WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: The assembly reference did not match the assembly definition found. ERR: Setup failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

谢谢!

推荐答案

我想你应该能够把这些作为的NuGet包安装到您的单元测试项目,并有如果包括这些绑定重定向到您的测试项目中的应用他们的工作。配置文件:

I think you should be able to install these as NuGet packages into your unit test project and have them work if you include these binding redirects to your test project's app.config file:

  <dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
  </dependentAssembly>

如果你有一个新的MVC项目并运行的NuGet的更新 - 包就可以了命令,这些都是自动创建。如果你还没有运行,并安装的NuGet包食入您的单元测试项目,那么你的单元测试项目就必须比你的web项目做了较新的程序集的引用。这将导致你看到的加载失败,我想。你只需要确保要么所有的组件都在整个解决方案常见的版本,或者所需的绑定重定向到位。而事实上,我认为绑定重定向反正必需的,因为DotNetOpenAuth组件已经被最近比 Microsoft.AspNet.WebPages.OAuth 包都有更新。

If you have a fresh MVC project and run NuGet's Update-Package command on it, these are automatically created. If you hadn't run that, and installed the NuGet packages fresh into your unit test project, then your unit test project would have references to newer assemblies than your web project did. That would cause the load failure you saw, I think. You just have to make sure that either all your assemblies have common versions across your solution, or that the required binding redirects are in place. And in fact I think the binding redirects are required anyway, since the DotNetOpenAuth assemblies have been updated more recently than the Microsoft.AspNet.WebPages.OAuth package has.

这篇关于我怎么拉DotNetOpenAuth集的引用到单元测试项目为ASP.NET MVC4解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆