visual-studio-2013 - NuGet 在每次更新时将 System.Runtime 添加到 web.config 导致运行时错误

标签 visual-studio-2013 asp.net-mvc-5 web-config nuget

我有一个包含多个项目的解决方案,其中两个是 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/

相关文章:

debugging - 此模块的调试信息中缺少源信息

ssl - 如何解决不受信任的证书错误?(TFS2013 构建并部署到 IIS)

c# - 使用 CookieAuthenticationProvider 调用 AuthenticationManager.SignIn() 后 ClaimsIdentity 信息存储在哪里

iis-7 - Web.Config 导致 500 内部服务器错误

c# - Visual Studio 图形调试器忽略工作像素着色器

c++ - 如何在 Visual Studio 中使用默认的 C++ 字符串构造函数?

sql-server - 使用 Dapper Dot Net 获取最后插入的 ID

c# - 在 asp.net mvc 5 中删除角色

xslt - 通过 configSource 链接到 web.config 的部分配置文件可以在 web 项目中转换吗?

asp.net - 在 ASP.Net 中使用 <httpRedirect> 传递参数