绑定重定向在测试项目中不起作用

发布于 2024-09-12 00:47:42 字数 2930 浏览 2 评论 0原文

在测试项目的 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"

我的 问题在这个很长的故事之后来自我对命名空间声明的理解只应该扰乱智能感知,为什么它会与程序集绑定混在一起???

When applying a binding redirect in the app.config of the test project. The runtime refuses to obey the redirect command and keeps searching for the old version of the assembly

<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>

well i had heard about the default namespace creating problems(from a very wise man) so i added the "xmlns="urn:schemas-microsoft-com:asm.v1".
Tried running the test case still no go.
Opened up Fusion Log Viewer checked the problem and wonders of wonder it is till looking for the old dll.
The really helpfull message given below was deciphered using this post
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.

My Though Process

This got me thinking why does it still not do the assembly redirection if the link is present in my config file.

So newbie that i am i just decided i will do exactly what the old man told me to do and removed the namespace declaration from the configuration element and hey presto it worked. xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

My Question after this very long story is from what i understand the namespace declarations is only supposed to mess with the Intellisense why is it screwing around with the assembly binding ???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似最初 2024-09-19 00:47:42

按设计将程序集加载到反射加载上下文中会忽略发布者策略和绑定重定向策略。 张俊峰在他的优秀博客中探讨了为什么会出现这种情况。< /a>

这里提出了类似的问题: 是否可以将 Assembly.ReflectionOnlyLoad 与发布者策略/程序集版本控制一起使用?

Loading an assembly into the Reflection load context by design ignores publisher policy and binding redirect policy. Junfeng Zhang examines why this is in his excellent blog.

A similar question is asked here: Is it possible to use Assembly.ReflectionOnlyLoad together with publisher policies / assembly versioning?

江湖正好 2024-09-19 00:47:42

MSTest.TestAdapterMSTest.TestFramework 从版本 1 更新到版本 2 为我解决了这个问题。

(准确地说,是从1.3.22.2.10

Updating MSTest.TestAdapter and MSTest.TestFramework from version 1 to version 2 resolved this issue for me.

(to be precise, from 1.3.2 to 2.2.10)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文