StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.92k stars 1.51k forks source link

The assembly for System.Runtime.CompilerServices.Unsafe could not be loaded in netcore2.1 #1668

Closed KillingMeNow closed 3 years ago

KillingMeNow commented 3 years ago

Got this error in netcore2.1 webapi,im using StackExchange.Redis 2.2.4(also tried downgrade to 2.0.513 but still got this),it only happens in my server,Windows Server2016.

[10:58:49.833 Error] The assembly for System.Runtime.CompilerServices.Unsafe could not be loaded; this usually means a missing assembly binding redirect - try checking this, and adding any that are missing; note that it is not always possible to add this redirects - for example 'azure functions v1'; it looks like you may need to use 'azure functions v2' for that - sorry, but that's out of our control at Pipelines.Sockets.Unofficial.Internal.Throw.InvalidOperation(String message) in //src/Pipelines.Sockets.Unofficial/Internal/Throw.cs:line 16 at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) in //src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1025

nhathongly commented 3 years ago

I got the same issue after upgrading to the latest version, but 2.0.519 still works well for me

ghost commented 3 years ago

Facing the same issue, pls some one help, we are using stack exchange redis in our production system and is causing issue.

ghost commented 3 years ago

We are using aws redis

kobewang commented 3 years ago

I have down grade to nuget stackexchange 1.6 ,and it's ok

jefflafay commented 3 years ago

I'm on .net core 2.2 and just updated to StackExchange.Redis v2.2.4. I was getting the same issue and then I resolved it by adding the latest stable System.Runtime.CompilerServices.Unsafe v5.0.0. Hope that helps someone ✌️

NickCraver commented 3 years ago

You can find info about this issue here: https://nickcraver.com/blog/2020/02/11/binding-redirects/ - I wrote a blog post because we had so many duplicate asks about this across many libraries (I agree, it's not intuitive). Closing this one out for the same duplicate reason :)