【问题标题】:binding redirect not working in test project绑定重定向在测试项目中不起作用
【发布时间】:2011-03-22 07:14:20
【问题描述】:

在测试项目的 app.config 中应用绑定重定向时。运行时拒绝服从重定向命令并不断搜索旧版本的程序集

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Msdcc.Common" publicKeyToken="9d9c15280f7f1425"/>
      <bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

我听说过默认命名空间会产生问题(来自一位非常聪明的人),所以我添加了“xmlns="urn:schemas-microsoft-com:asm.v1"。 尝试运行测试用例仍然不行。 打开 Fusion Log Viewer 检查问题和奇迹,直到寻找旧的 dll。 下面给出的真正有用的信息是使用这篇文章破译的 http://msdn.microsoft.com/en-us/magazine/dd727509.aspx

*** Assembly Binder Log Entry  (28/07/2010 @ 18:59:36) ***

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

Assembly manager loaded from:  C:\WINNT\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = BELGACOM\id820374
LOG: DisplayName = Msdcc.Common, Version=2.2.0.0, Culture=neutral, PublicKeyToken=9d9c15280f7f1425
 (Fully-specified)
LOG: Appbase = file:///c:/data/source/explorev1/explore.root/explore/euc.explore.domainobjectstest/bin/debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: Using application configuration file: c:\data\source\explorev1\explore.root\explore\euc.explore.domainobjectstest\bin\debug\euc.explore.domainobjectstest.dll.config
LOG: Using machine configuration file from C:\WINNT\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///c:/data/source/explorev1/explore.root/explore/euc.explore.domainobjectstest/bin/debug/Msdcc.Common.DLL.
LOG: Assembly download was successful. Attempting setup of file: c:\data\source\explorev1\explore.root\explore\euc.explore.domainobjectstest\bin\debug\Msdcc.Common.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Msdcc.Common, Version=2.4.0.0, Culture=neutral, PublicKeyToken=9d9c15280f7f1425
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我的 虽然 过程

这让我想,如果我的配置文件中存在链接,为什么它仍然不执行程序集重定向。

所以我是新手,我刚刚决定我将完全按照老人告诉我的去做,并从配置元素中删除命名空间声明,嘿,它很快就起作用了。 xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

我的 问题 在这个很长的故事之后,我理解命名空间声明只应该与 Intellisense 混淆,为什么它会与程序集绑定搞混? ??

【问题讨论】:

  • 抱歉,Lukas 回复晚了,使用 vs2008 SP1。
  • 你找到解决这个问题的办法了吗...?

标签: c# binding assemblies


【解决方案1】:

通过设计将程序集加载到反射加载上下文中会忽略发布者策略和绑定重定向策略。 Junfeng Zhang examines why this is in his excellent blog.

这里提出了类似的问题:Is it possible to use Assembly.ReflectionOnlyLoad together with publisher policies / assembly versioning?

【讨论】:

    猜你喜欢
    • 2011-03-30
    • 1970-01-01
    • 2012-07-17
    • 2012-02-14
    • 2012-02-13
    • 2012-09-01
    相关资源
    最近更新 更多