Resolved Could not load file or assembly System.Runtime.CompilerServices.Unsafe

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
361
Programming Experience
10+
Hello guys,

I have a web API that was working without a problem. But today I am getting this error on the production server:

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, 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)

There is no such problem with the local machine. I tried to update this System.Runtime.CompilerServices.Unsafe but still having the same problem. Any ideas on how to fix it?

Best Regards.
 
Chances are that you actually changed something like updated a Nuget package or two, or had some patches applied to your machine.

See StackOverflow response on how to deal people have dealt with a similar issue when using Redis and its transitive dependencies.
 
Thank you @Skydiver, adding this assembly to web.config solved my issue.

System.Runtime.CompilerServices.Unsafe:
dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
 
Back
Top Bottom