Could not load file or assembly System.Runtime.CompilerServices.Unsafe on a clean autofac.mv5 installation

0

I just installed autofac.Mvc5 6.0 on my .net framework 4.7.2 installation.

And without adding any code other than adding the nuget package I get this error:

Could not load file or assembly System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of it's dependences. The found Assembly's manifest definition does not match the Assembly reference. (Exception from HRESULT: 0x80131040)

Anyone got any idea?

asp.net-mvc
autofac
asked on Stack Overflow Jan 4, 2021 by President Camacho • edited Jan 4, 2021 by President Camacho

1 Answer

1

You probably have another library that uses a different version of System.Runtime.CompilerServices.Unsafe. What's in web.config?
Did you tried bindingRedirect?

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

If you have a newer version replace it in the newVersion above.

answered on Stack Overflow Jan 4, 2021 by iamdlm

User contributions licensed under CC BY-SA 3.0