绑定重定向在测试项目中不起作用
在测试项目的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按设计将程序集加载到反射加载上下文中会忽略发布者策略和绑定重定向策略。 张俊峰在他的优秀博客中探讨了为什么会出现这种情况。< /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?
将
MSTest.TestAdapter
和MSTest.TestFramework
从版本 1 更新到版本 2 为我解决了这个问题。(准确地说,是从
1.3.2
到2.2.10
)Updating
MSTest.TestAdapter
andMSTest.TestFramework
from version 1 to version 2 resolved this issue for me.(to be precise, from
1.3.2
to2.2.10
)