在一个 VB 项目中,我使用 Add-in-Express (v905-b4661-vs-std) 和 NuGet 包 Azure.Storage.Files.Shares (12.8.0) (Visual Studio 16.11, DotNet 4.7.2) 并得到了一个问题:
Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe,
Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
我尝试通过将其添加到我的 app.config 文件的配置部分来通过程序集重定向来解决此问题:
<runtime>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe"
publicKeyToken="b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="4.0.4.1" newVersion="4.0.6.0"/>
</dependentAssembly>
</runtime>
但是错误仍然会弹出(我已经尝试过Auto-generate binding redirects
为我的项目选中和未选中,但这似乎没有什么区别)。
我还使用 4.0.5.0 作为新版本,因为当我通过[reflection.assemblyname]::getassemblyname('X.dll').version
... CompilerServices.unsafe dll 上的 Powershell 命令破解它时,它被报告为程序集版本,该 dll 在构建后位于项目的 ...bin\debug 文件夹中,但错误仍然弹出。
知道为什么重定向在这里不起作用(似乎)吗?
顺便说一句:我在另一篇文章中找到了版本检查命令;不记得是哪一个,所以我不能感谢作者,但这是我迄今为止看到的最简单的解决方案。