每当我尝试使用应用程序洞察和 Entity Framework 运行 webjob 项目时,我都会收到此错误。
System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, 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)'
我已经安装了以下nuget包
Microsoft.Azure.WebJobs.Logging.ApplicationInsights 版本 2.1.0-beta4
Microsoft.Extensions.Logging 版本 2.0.0
Microsoft.Extensions.Logging.Console 版本 2.0.0。
这一切都适用于新的 Visual studio 2017 webjob 项目,当我尝试包含现有代码库(主要使用 Entity Framework )时,我收到此错误。当我查看有效的引用文献时,我没有 System.Runtime.InteropServices.RuntimeInformation,但它已通过 Entity Framework 添加到项目中。它似乎是 .net 标准的一部分,但为什么我的新控制台应用程序不需要 .net 标准!
我不确定为什么它要寻找版本 0.0.0.0,因为我拥有的版本是 4.0.2.0
我也尝试将其添加到项目文件中,但这不起作用。
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
任何帮助将不胜感激
非常感谢
最佳答案
确认 dwilliss 的上述评论也对我有用。解决方案是摆脱:
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
(在我的例子中,来自 app.config,用于 Windows 服务。)我的项目仅间接依赖于 System.Runtime.InteropServices.RuntimeInformation。它是我导入的 NuGet 包的依赖项。
关于c# - 无法加载文件或程序集“System.Runtime.InteropServices.RuntimeInformation”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48520188/