【发布时间】:2017-12-03 03:52:37
【问题描述】:
我们有一个由一堆小工具组成的项目。
他们所有人都使用 MongoDB,并且没有一个没有一次或多次因该错误而惹恼我:
System.IO.FileNotFoundException 发生 HResult=0x80070002
消息=无法加载文件或程序集 'System.Runtime.InteropServices.RuntimeInformation,版本=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其之一 依赖关系。
它们都有一个我什至不知道其来源的 app.config 文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
同时,NuGet 有如下一行:
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net462" />
所以,很明显,我有 Interop lib 4.3.0 版,但我不知道某些文件需要 4.0.1.0 版(请注意,甚至没有相同的位数)。 这通常是通过删除 lib,重新添加它来解决的......很快,同样的问题会再次出现,通常是在一些 NuGet 更新等之后。
这似乎只发生在我们拥有 MongoDB 库的项目上,其中 NuGet 中的版本号与创建 app.config 文件的任何内容不同步。
【问题讨论】: