Azure Redis Exception while executing function: MyFunction -> Unable to find assembly 'MySolution.MyProject.MyService
Someone asked on Stack Overflow:
While using CachingFramework.Redis I am trying to insert an object into a key, field hash…
enter code here var map = new MyMapping { DataSourceId = source.DataSourceId, ExternalId = source.ExternalId, StoreId = source.StoreId ?? 0, LastConnection = source.LastConnection, ApiKey = source.ApiKey }; Context.Cache.SetHashed("MyRedisKey", "MyFieldKey", map, TimeSpan.FromHours(1));But, when I try to get the hashed value back out…
var MyCachedValue = Context.Cache.GetHashed<MyMapping>(("MyRedisKey", "MyFieldKey");I get the error…
“Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: MyFunction ---> System.Runtime.Serialization.SerializationException : Unable to find assembly ‘MySolution.MyProject.MyService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.FunctionInvocationFilterInvoker.InvokeAsync(Object instance,Object[] arguments)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)\r\n …
I posted the following answer, which was chosen as the accepted answer and received 1 upvote:
Are you setting and retrieving the value in different assemblies? It looks like that might be the case.
In that event, you need your Map to be defined in a shared assembly that is referenced by both the project that sets the value as well as the project that gets the value.
- GetterProject
- SetterProject
- SharedModels
Both 1 and 2 should reference 3, and that is where you should define the objects stored in your cache.
Originally posted on Stack Overflow — 1 upvotes (accepted answer). Licensed under CC BY-SA.