执行函数时出现 Azure Redis 异常:MyFunction -> 无法找到程序集 'MySolution.MyProject.MyService
Azure Redis Exception while executing function: MyFunction -> Unable to find assembly 'MySolution.MyProject.MyService
在使用 CachingFramework.Redis 时,我试图将对象插入到键、字段哈希中...
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));
但是,当我尝试取回散列值时...
var MyCachedValue = Context.Cache.GetHashed<MyMapping>(("MyRedisKey", "MyFieldKey");
我收到错误...
"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 ....
您是否在不同的程序集中设置和检索值?看起来可能是这样。
在那种情况下,您需要在一个共享程序集中定义您的 Map
,该程序集被设置值的项目和获取值的项目引用。
- Getter项目
- 二传项目
- 共享模型
1 和 2 都应该引用 3,这是您应该定义存储在缓存中的对象的地方。
在使用 CachingFramework.Redis 时,我试图将对象插入到键、字段哈希中...
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));
但是,当我尝试取回散列值时...
var MyCachedValue = Context.Cache.GetHashed<MyMapping>(("MyRedisKey", "MyFieldKey");
我收到错误...
"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 ....
您是否在不同的程序集中设置和检索值?看起来可能是这样。
在那种情况下,您需要在一个共享程序集中定义您的 Map
,该程序集被设置值的项目和获取值的项目引用。
- Getter项目
- 二传项目
- 共享模型
1 和 2 都应该引用 3,这是您应该定义存储在缓存中的对象的地方。