Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Fabric with F# not working

Tags:

I tried to convert the default template for "Service Fabric Applicatoin" with "Actor Service" from C# to F#.

Here is the github repo.

I can compile everything but when I deploy it to the local cluster I get System.ArgumentNullException. Does anyoune know what is wrong here?

Here is the stack trace (it's in german, sorry):

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.
like image 916
ThisFunctionalTom Avatar asked Nov 13 '16 07:11

ThisFunctionalTom


1 Answers

Your problem is very subtle. I stumbled across this myself.

Each parameter in the actor interface must have an explicit name. Thanks to Isaac Abraham who mentioned this in his blog post (But this post is very outdated)

Change your actor interface from this:

type IMyActor =
  inherit IActor
  abstract member GetCountAsync : unit -> Task<int>
  abstract member SetCountAsync : int -> Task

To the following: (notice the count argument)

type IMyActor =
  inherit IActor
  abstract member GetCountAsync : unit -> Task<int>
  abstract member SetCountAsync : count: int -> Task

After this change your example worked fine for me.

like image 110
Philipp Haider Avatar answered Sep 23 '22 16:09

Philipp Haider