Could not load file or assembly System.Runtime, Version=4.0.0.0

edited August 23
Hi,

I've built a ASP.NET MVC 5 website, and I've taken the bin folder to then reference the business logic DLLs in my LinqPad queries.

ASP.NET MVC website is built against .NET 4.7.1

Upon running a query I get the following error:

Message
Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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)

Source
MySqlConnector

I do have references to DLLs which are build for .NET Standard, but not .NET Core.


System.Runtime.dll is in the directory with the other DLLs references and I've changed the .config file to redirect to the correct version like so:

<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>

But I still get the error every time

Is anyone able to shed any light on this?

Comments

  • Sorry this is a bit late but I just joined and seen this.

    If you are still having this issue I ran into something similar due to Nuget and other "shortcuts" automatically referencing and pulling in dlls for versions I didn't need. I resolved my issue by doing a grep on System.Runtime from out side the solution to bring up all references for me to look through and there were build scripts added that were automatically redirecting libraries...

    You should try using something like baregrep or dngrep to search through all the files to see if there is another hidden reference or build script that may be redirecting this that you aren't seeing . Good luck!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!