Ble*_*ter 1 c# visual-studio nuget
我知道这被问了很多,但我尝试了所有解决方案但没有奏效!
这是在调试模式下运行时的错误:
System.IO.FileLoadException: '无法加载文件或程序集 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)'
我试图消除所有bin和obj文件夹的所有projects在我的solution。还删除了Packages文件夹。
还删除了所有配置文件中的此项:
<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>
Run Code Online (Sandbox Code Playgroud)
也将newVersion上面代码中的值更改为4.0.0.0但绝不喜欢工作!
当我卸载项目并对其进行编辑时,我看到这一行:
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?提前致谢。
小智 5
可能有点晚了,但我在我们的一台带有 .net 4.6.2 的旧版构建服务器上遇到了类似的 MongoDB 驱动程序(从 2.5 升级到 2.7)问题。奇怪的是,它在使用 Visual Studio 构建时在本地机器上运行。问题在于 NuGet 本身,以及在包更新期间添加的错误程序集绑定。我们必须手动检查正确的程序集版本并覆盖 app.config 中的值。
确保通过在目标计算机上添加以下注册表项来激活详细日志记录:HKLM\Software\Microsoft\Fusion > EnableLog (DWORD) 设置为 1
然后,您可以获得更详细的信息,具体是哪个 DLL 导致了问题。
以下 PowerShell 命令可以帮助找到正确的程序集版本。例如对于 InteropServices:
[System.Reflection.Assembly]::LoadFrom("C:\path_to_your_release_folder\System.Runtime.InteropServices.RuntimeInformation.dll").GetName().Version
Run Code Online (Sandbox Code Playgroud)
在我们的例子中是:
Major Minor Build Revision
----- ----- ----- --------
4 0 1 0
Run Code Online (Sandbox Code Playgroud)
在 app.config 中 NuGet 写了 4.0.2.0,所以我们只是将其更改为 4.0.1.0:
<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>
Run Code Online (Sandbox Code Playgroud)
正如预期的那样,一切都自动恢复正常。
因此,确定要使用哪个绑定的唯一方法是使用我上面描述的方法自己检查版本。
| 归档时间: |
|
| 查看次数: |
3578 次 |
| 最近记录: |