所以我正在写第一个演员服务,我遇到了这个错误
System.MethodAccessException: Attempt by method 'Microsoft.ServiceFabric.Services.Remoting.Description.InterfaceDescription..ctor(System.String, System.Type, Microsoft.ServiceFabric.Services.Remoting.Description.MethodReturnCheck)' to access method 'Microsoft.ServiceFabric.Services.Common.IdUtil.ComputeId(System.Type)' failed.
at Microsoft.ServiceFabric.Services.Remoting.Description.InterfaceDescription..ctor(String remotedInterfaceKindName, Type remotedInterfaceType, MethodReturnCheck methodReturnCheck)
at Microsoft.ServiceFabric.Actors.Remoting.Builder.ActorCodeBuilder.<BuildProxyGenerator>b__5(Type t)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyGeneratorBuilder`2.Build(Type proxyInterfaceType, IEnumerable`1 interfaceDescriptions)
at Microsoft.ServiceFabric.Services.Remoting.Builder.CodeBuilder.Microsoft.ServiceFabric.Services.Remoting.Builder.ICodeBuilder.GetOrBuildProxyGenerator(Type interfaceType)
at Microsoft.ServiceFabric.Actors.Remoting.Builder.ActorCodeBuilder.GetOrCreateProxyGenerator(Type actorInterfaceType)
at Microsoft.ServiceFabric.Actors.Client.ActorProxyFactory.CreateActorProxy[TActorInterface](Uri serviceUri, ActorId actorId, String listenerName)
at Microsoft.ServiceFabric.Actors.Client.ActorProxy.Create[TActorInterface](ActorId actorId, Uri serviceUri, String listenerName)
我有一个actor服务和一个无状态的Web API服务。在Web API控制器中,我试图像这样获得一个actor处理:
var actorServiceProxy = ActorProxy.Create<IPaymentActor>(ActorId.CreateRandom(), new Uri("fabric:/PaymentService/PaymentActorService"));
这就是抛出异常的地方。有什么想法吗?
编辑:每个请求包含的actor定义。 PaymentInfo对象标记为DataContract FWIW
public interface IPaymentActor : IActor
{
/// <summary>
/// TODO: Replace with your own actor method.
/// </summary>
/// <returns></returns>
Task<PaymentInfo> GetPaymentInformation(CancellationToken cancellationToken);
/// <summary>
/// TODO: Replace with your own actor method.
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
Task SetPaymentInformation(PaymentInfo info, CancellationToken cancellationToken);
}
答案 0 :(得分:1)
是的,这是正确的。 Microsoft.ServiceFabric.Services.Remoting在2.5.216版本中添加,它依赖于Microsoft.ServiceFabric.Services.2.5.216 nuget包。所以,一旦你升级了所有的nuget包,它就能正常运行。
答案 1 :(得分:0)
我明白了。
错误匹配Microsoft.ServiceFabric.Actors库引用。
文件&gt;新项目&gt;服务面料&gt;对于Microsoft.ServiceFabric.Actors包,Actor project scaffolding默认为v2.4.164。
然而,当我去添加一个Web前端并通过NuGet添加该项目时,它添加了最新版本(在撰写本文时为v2.5.216)。这在RPC调用期间表现为库中的低级异常。我将向Service Fabric团队指出这一点,并希望他们能够提供更有意义的错误消息检查。与此同时,如果你偶然发现了这个错误,请检查一下。