"密钥没有出现在字典中#34;使用通用奥尔良谷物时

时间:2016-10-27 21:52:11

标签: c# orleans

刚刚升级到1.3.0并且遇到了仿制药问题。

显示此问题的示例界面和类:

public interface IGenericTest<T> : IGrainWithIntegerKey
{
    Task<T> PrintType(T obj);
}



public class GenericTestGrain<T> : Grain, IGenericTest<T>
{
    public Task<T> Print(T obj)
    {
        Debug.WriteLine("TEST");
        return Task.FromResult(obj);
    }
}

然后使用它:

var grain = await GrainFactory.GetGrain<IGenericTest<int>>(0); // Runs without error.
await grain.Print(1);

获得谷物似乎很好,但是当我在谷物上调用方法时,我得到了:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Orleans.InterceptedMethodInvokerCache.GetInterfaceToImplementationMap(Int32 interfaceId, Type implementationType)
at Orleans.InterceptedMethodInvokerCache.CreateInterceptedMethodInvoker(Type implementationType, Int32 interfaceId, IGrainMethodInvoker invoker)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Orleans.InterceptedMethodInvokerCache.GetOrCreate(Type implementationType, Int32 interfaceId, IGrainMethodInvoker invoker)
at Orleans.Runtime.InsideRuntimeClient.InvokeWithInterceptors(IAddressable target, InvokeMethodRequest request, IGrainMethodInvoker invoker)
at Orleans.Runtime.InsideRuntimeClient.<Invoke>d__57.MoveNext()

我有什么遗失的东西吗?也许一些新的配置?这与我之前使用的旧版本一起工作正常。

编辑:

似乎是调用拦截器的一个问题:

providerRuntime.SetInvokeInterceptor((method,request,grain,invoker)=&gt; {     return invoker.Invoke(grain,request); });

删除后,一切正常。

1 个答案:

答案 0 :(得分:0)

这里回答的问题是:https://github.com/dotnet/orleans/issues/2358 这是一个错误。