调用 Service Fabric Actor 服务时出现 MethodAccessException
MethodAccessException when calling into a Service Fabric Actor service
所以我正在编写我的第一个演员服务,我 运行 陷入了这个错误
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)
我有一个演员服务和一个无状态网络 API 服务。在网络 API 控制器中,我正在尝试像这样获取演员句柄:
var actorServiceProxy = ActorProxy.Create<IPaymentActor>(ActorId.CreateRandom(), new Uri("fabric:/PaymentService/PaymentActorService"));
这就是抛出异常的地方。有什么想法吗?
编辑:每个请求都包含参与者定义。 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);
}
我想通了。
不匹配 Microsoft.ServiceFabric.Actors 库引用。
文件 > 新建项目 > Service Fabric > Actor Project 脚手架默认为包 Microsoft.ServiceFabric.Actors.
的 v2.4.164
然而,当我去添加一个 Web 前端并通过 NuGet 添加该项目时,它添加了最新的(在撰写本文时为 v2.5.216)。在 RPC 调用期间,这表现为库中的低级异常。我会向 Service Fabric 团队指出这一点,并希望他们能够提供包含更有意义的错误消息的检查。同时,如果您偶然发现了这个错误,请检查一下。
是的,没错。 Microsoft.ServiceFabric.Services.Remoting 是在 2.5.216 版本中添加的,它依赖于 Microsoft.ServiceFabric.Services.2.5.216 nuget 包。因此,一旦您升级了所有 nuget 包,它就可以正常工作。
所以我正在编写我的第一个演员服务,我 运行 陷入了这个错误
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)
我有一个演员服务和一个无状态网络 API 服务。在网络 API 控制器中,我正在尝试像这样获取演员句柄:
var actorServiceProxy = ActorProxy.Create<IPaymentActor>(ActorId.CreateRandom(), new Uri("fabric:/PaymentService/PaymentActorService"));
这就是抛出异常的地方。有什么想法吗?
编辑:每个请求都包含参与者定义。 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);
}
我想通了。
不匹配 Microsoft.ServiceFabric.Actors 库引用。
文件 > 新建项目 > Service Fabric > Actor Project 脚手架默认为包 Microsoft.ServiceFabric.Actors.
的 v2.4.164然而,当我去添加一个 Web 前端并通过 NuGet 添加该项目时,它添加了最新的(在撰写本文时为 v2.5.216)。在 RPC 调用期间,这表现为库中的低级异常。我会向 Service Fabric 团队指出这一点,并希望他们能够提供包含更有意义的错误消息的检查。同时,如果您偶然发现了这个错误,请检查一下。
是的,没错。 Microsoft.ServiceFabric.Services.Remoting 是在 2.5.216 版本中添加的,它依赖于 Microsoft.ServiceFabric.Services.2.5.216 nuget 包。因此,一旦您升级了所有 nuget 包,它就可以正常工作。