程序集绑定重定向不起作用

2023-12-25

我正在尝试使用以下 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”,但这不起作用,尽管我认为这不会产生任何影响。

据我了解,重定向绑定的全部目的是使用与构建程序的版本不匹配的版本。我在这里完全错过了什么吗?我想做的事情是否可能,如果可以,知道为什么它不起作用吗?

干杯, 亚当


配置 xml 中的任何拼写错误都可能是原因。加载程序无法看到您的配置。 我也头痛了一个小时,直到我意识到错误是在模式名称中的字符“=”而不是“-”中:

<assemblyBinding xmlns="urn:schemas=microsoft-com:asm.v1">

只需仔细检查所有属性名称和值即可。我想“PublicKeyToken”应该是“publicKeyToken”

这应该有效:

<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

程序集绑定重定向不起作用 的相关文章

随机推荐