【发布时间】:2011-03-30 06:04:36
【问题描述】:
我正在尝试使用以下 app.config 设置程序集绑定重定向:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.AnalysisServices"
PublicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="10.0.0.0"
newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我在 GAC 中版本为 9.0.242.0 的机器上运行该程序,并使用指定的公钥令牌。不过,CLR 似乎甚至没有尝试重定向绑定以使用该版本。
这是我在 fuslogvw.exe 中得到的:
LOG: This bind starts in default load context.
LOG: Using application configuration file: \Debug\AssemblyRedirectPOC.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Microsoft.AnalysisServices, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL /Debug/Microsoft.AnalysisServices.DLL.
LOG: Attempting download of new URL /Debug/Microsoft.AnalysisServices/Microsoft.AnalysisServices.DLL.
LOG: Attempting download of new URL /Debug/Microsoft.AnalysisServices.EXE.
LOG: Attempting download of new URL /Debug/Microsoft.AnalysisServices/Microsoft.AnalysisServices.EXE.
LOG: All probing URLs attempted and failed.
当我尝试将 9.0.242.0 版本的 dll 放入探测路径时,我得到了这个:
LOG: Assembly download was successful. Attempting setup of file: \Debug\Microsoft.AnalysisServices.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Microsoft.AnalysisServices, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
请注意,我还尝试将重定向更改为在 app.config 中使用“9.0.242.0”而不是“9.0.0.0”,但这没有用,尽管我认为这不会有任何区别。
据我了解,重定向绑定的全部意义在于使用与构建程序的版本不匹配的版本。我在这里完全错过了什么吗?我正在尝试做的事情是否可行,如果可以,知道为什么它不起作用吗?
干杯, 亚当
【问题讨论】:
标签: c# .net binding assemblies reference