Errors when trying to use StackExchange REDIS in Azure Cloud Service Worker Role

2

I have a solution hosted in Azure that is using ServiceStack.Redis 2.0.601. App Services (Web API) and On-Premise windows services are all working as expected but the Cloud service worker roles are throwing binding errors.

  1. Add Binding redirect and enable auto binding redirect in the worker role.
  2. Use ILSpy to verify the versions that are copied by the build have same version as defined in the binding redirect.
  3. Use fuslogvw.exe to catch binding errors but couldn't make it get any data from the Cloud Service Emulator

I'm running the same code with same app configs in other type of projects and all working great

The code is very simple, Create a cloud service with one worker role. Add StachExchange.Redis nuget version 2.0.601 and try to connect a REDIS instance using the following line:

var connection = ConnectionMultiplexer.Connect(#ConnectionString#);

This is the only line I have in the code inside WorkerRole.OnStart Method.

System.BadImageFormatException: 'Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)'

azure-cloud-services
azure-worker-roles
servicestack.redis
assembly-binding-redirect
asked on Stack Overflow Oct 31, 2019 by Jaffi

1 Answer

0

I was getting similar errors, and realized I needed to add a bunch of additional Nuget packages.

  • System.Buffers
  • System.IO.Pipelines
  • System.Memory
answered on Stack Overflow Feb 7, 2020 by medianJoe

User contributions licensed under CC BY-SA 3.0