简体   繁体   中英

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

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)'

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

  • System.Buffers
  • System.IO.Pipelines
  • System.Memory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM