Search code examples
.netredisservicestackredis-sentinelservicestack-bsd

Could not load type 'ServiceStack.Redis.RedisSentinel' from assembly 'ServiceStack.Redis, Version=3.9.48.0, Culture=neutral, PublicKeyToken=null


Currently in my application I am trying to implement application caching for which I have used RedisSentinel.

We have a common assembly which is having all code and configurations implemented for Redis, and that assembly is having ServiceStack version 4.5.4.

I am referring the same assembly (DLL) in my project, but we are having ServiceStack 3.9.48 and currently no plans to upgrade it.

While trying to access instance of RedisSentinel, I am getting following error:

Could not load type 'ServiceStack.Redis.RedisSentinel' from assembly 'ServiceStack.Redis, Version=3.9.48.0, Culture=neutral, PublicKeyToken=null

Can anyone please guide how to resolve this issue?

The ultimate goal is to use RedisSentinel in my application which is using ServiceStack 3.9.48, and I would prefer to access the above mentioned custom assembly which we are already referencing in other projects.

Any help on this will be much appreciated.

Thanks


Solution

  • an anyone please guide how to resolve this issue?

    Options:

    • update the version that you ship to 4.5.4 (and do any work necessary in the upgrade)
    • don't use any API features that don't exist in 3.9.48
      • one way to enforce this is to downgrade the first assembly to use that version
    • use two completely isolated processes (technically, you could do it with app-domains, but that is a lot of mess) for the two tasks: one which ships and references 3.9.48, one which ships and references 4.5.4

    Basically, you can only load one version of the dll into an app-domain. If you reference both 4.5.4 and 3.9.48 then what happens at runtime depends on which version loads, i.e. which version you ship in your package.

    • if you ship 3.9.48, then the code that expects 4.5.4 can fail at any time, in particular if it uses an API that didn't exist in 3.9.48 but which exists in 4.5.4
    • if you ship 4.5.4, then the code that expects 3.9.48 can fail at any time, in particular if it uses an API that has been removed or had any breaking change (under semver rules, breaking changes are allowed between 3.* and 4.*)

    In the general case, I would advise "use the newer", as it may contain bug-fixes for features that existed in 3.9.48 that you are using. Of course, newer code can also just mean new bugs :)