升级Bond包至11.0.0后Assembly加载失败问题求助
Bond程序集加载失败问题求助
版本升级背景
项目原本使用的Bond包引用如下:
<PackageReference Include="Bond.Runtime.CSharp"> <Version>5.3.1</Version> </PackageReference> <PackageReference Include="Bond.Core.CSharp"> <Version>5.3.1</Version> </PackageReference> <PackageReference Include="Bond.Core.CSharp"> <Version>5.3.1</Version> </PackageReference>
将所有Bond包版本升级至11.0.0后,出现程序集加载异常。
初始异常信息
在Microsoft.Osgs.Infra.Monitoring.dll中发生类型为'System.IO.FileLoadException'的异常,但未在用户代码中处理 无法加载文件或程序集“Bond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或其依赖项之一。
问题分析
Microsoft.Osgs.Infra.Monitoring.dll依赖Bond 1.0.0版本:
- 使用Bond 5.3.1时,输出目录生成的Bond.dll文件版本为1.0.0.0,能满足依赖要求
- 升级到Bond 11.0.0后,输出目录生成的Bond.dll版本变为11.0.0.100,与依赖的版本不匹配
尝试的解决措施:添加绑定重定向
在应用配置文件中添加以下绑定重定向配置:
<dependentAssembly> <assemblyIdentity name="Bond" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-99.0.0.0" newVersion="11.0.0.100" /> </dependentAssembly>
绑定重定向后的异常
配置生效后,仍出现加载失败异常:
在Microsoft.Osgs.Infra.Monitoring.dll中发生类型为'System.IO.FileLoadException'的异常,但未在用户代码中处理 无法加载文件或程序集“Bond, Version=11.0.0.100, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或其依赖项之一。
关键验证信息与Fusion日志
- 已确认输出目录中存在版本为11.0.0.100的Bond.dll文件
- 查看Fusion加载日志,发现核心问题:
LOG: DisplayName = Bond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Redirect found in application configuration file: 1.0.0.0 redirected to 11.0.0.100. LOG: Post-policy reference: Bond, Version=11.0.0.100, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: Assembly download was successful. Attempting setup of file: C:\Users\username\Source\Repos\project\target\distrib\Debug\AnyCPU\dev\WebApi\ProjectA\Bond.dll LOG: Assembly Name is: Bond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: The assembly reference did not match the assembly definition found. ERR: Run-from-source setup phase failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
日志显示:绑定重定向已生效,但加载时实际读取到的Bond.dll程序集版本仍为1.0.0.0,与重定向后的目标版本11.0.0.100不匹配,导致加载失败。
请求协助解决该程序集加载失败问题。
内容的提问来源于stack exchange,提问作者Jugal
相关产品推荐
相关产品推荐

