我有一个包含多个项目的解决方案,其中两个是 MVC5 网络应用程序。
每次我在 any 项目中更新 any nuget 包时,都会修改 mvc 应用程序的 web.config,添加以下内容:
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
</dependentAssembly>
这会导致运行时错误:
[BadImageFormatException: Could not load file or assembly 'System.Runtime' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
如果我从 web.config 中删除这个条目,一切正常,只是每次都要记住这样做很烦人。
知道为什么会这样吗?
最佳答案
所以这是我在位置手动添加到 system.runtime.dll 的链接后出现的
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Runtime.dll
删除它可以解决这个问题,但我首先添加它的原因是因为我需要一个需要构建该 dll 的可移植 nuget 包。所以我最终将它留在原地并一直手动删除它。 :(
关于visual-studio-2013 - NuGet 在每次更新时将 System.Runtime 添加到 web.config 导致运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32739137/