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

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
215
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.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+
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.
 

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
215
Programming Experience
10+
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>
 
Top Bottom