F#的Service Fabric无法正常工作

tom*_*tom 5 c# f# azure-service-fabric

我试图将带有“角色服务”的“服务结构应用程序”的默认模板从C#转换为F#。

这是github 仓库

我可以编译所有内容,但是当我将其部署到本地群集时会得到System.ArgumentNullException。任何人都知道这是怎么回事吗?

这是堆栈跟踪(抱歉,它是德语):

bei System.Reflection.Emit.FieldBuilder..ctor(TypeBuilder typeBuilder, String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
bei System.Reflection.Emit.TypeBuilder.DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
bei System.Reflection.Emit.TypeBuilder.DefineField(String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
bei Microsoft.ServiceFabric.Services.Remoting.Builder.MethodBodyTypesBuilder.BuildRequestBodyType(ICodeBuilderNames codeBuilderNames, CodeBuilderContext context, MethodDescription methodDescription)
bei Microsoft.ServiceFabric.Services.Remoting.Builder.MethodBodyTypesBuilder.Build(ICodeBuilderNames codeBuilderNames, CodeBuilderContext context, MethodDescription methodDescription)
bei Microsoft.ServiceFabric.Services.Remoting.Builder.MethodBodyTypesBuilder.Build(InterfaceDescription interfaceDescription)
bei Microsoft.ServiceFabric.Services.Remoting.Builder.CodeBuilder.Microsoft.ServiceFabric.Services.Remoting.Builder.ICodeBuilder.GetOrBuildMethodBodyTypes(Type interfaceType)
bei Microsoft.ServiceFabric.Services.Remoting.Builder.MethodDispatcherBuilder`1.Build(InterfaceDescription interfaceDescription)
bei Microsoft.ServiceFabric.Services.Remoting.Builder.CodeBuilder.Microsoft.ServiceFabric.Services.Remoting.Builder.ICodeBuilder.GetOrBuilderMethodDispatcher(Type interfaceType)
bei Microsoft.ServiceFabric.Actors.Remoting.Builder.ActorCodeBuilder.GetOrCreateMethodDispatcher(Type actorInterfaceType)
bei Microsoft.ServiceFabric.Actors.Remoting.Runtime.ActorMethodDispatcherMap..ctor(ActorTypeInformation actorTypeInformation)
bei Microsoft.ServiceFabric.Actors.Runtime.ActorRuntime.<RegisterActorAsync>d__7`1.MoveNext()
---  Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei Program.main(String[] argv) in C:\Users\tomas\Projects\playground\MyServiceFabricApp\MyActor\Program.fs:Zeile 18.
Run Code Online (Sandbox Code Playgroud)

小智 4

你的问题很微妙。我自己偶然发现了这一点。

Actor 接口中的每个参数都必须有一个明确的名称。感谢艾萨克·亚伯拉罕在他的博客文章中提到了这一点中提到了这一点(但这篇文章已经非常过时了)

从此改变你的演员界面:

type IMyActor =
  inherit IActor
  abstract member GetCountAsync : unit -> Task<int>
  abstract member SetCountAsync : int -> Task
Run Code Online (Sandbox Code Playgroud)

以下内容:(注意 count 参数)

type IMyActor =
  inherit IActor
  abstract member GetCountAsync : unit -> Task<int>
  abstract member SetCountAsync : count: int -> Task
Run Code Online (Sandbox Code Playgroud)

进行此更改后,您的示例对我来说效果很好。