NuGet adds System.Runtime to web.config on every update causing run-time error

3

I have a solution with multiple projects, two of them being MVC5 web apps.
Every time I update any nuget package in any project, the mvc apps' web.config is modified, adding the following:

  <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>

This causes runtime error:

[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)]

If I remove this entry from the web.config, everything works OK, it's just annoying to remember to do it every time.
Any ideea why is this happening?

visual-studio-2013
asp.net-mvc-5
web-config
nuget
asked on Stack Overflow Sep 23, 2015 by Attila Szasz

1 Answer

-1

so this came up for me after I had manually added a link to system.runtime.dll at location C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Runtime.dll

Removing this fixes this problem but the reason I added it in the first place was because I needed a portable nuget package that required that dll to build. So I ended up leaving it in place and manually deleting it all the time. :(

answered on Stack Overflow Jul 8, 2016 by Lloyd Stockman

User contributions licensed under CC BY-SA 3.0