Actors Referencing .NET Standard 'Works On My Machine'
So the age old ‘works on my machine’ is back at it again with Service Fabric Reliable Actors and likely Reliable Services in general (Stateless or Stateful). As you can see from the status my local dev cluster is reporting ‘it works on my machine’. I should be done right? 😊
I have been trying to deploy some Actors that I developed to a Stand Alone Cluster that I built on a physical server in my Home Lab. These Actors reference a Model library that I’ve setup as .NET Standard 2.0. I intended to use these models as data contracts on my ASP.NET Core WebAPIs as well as my Actor interfaces. It was all working on my local development cluster but when I started deploying to my StandAlone Cluster it just went bonkers.
As per my last post on the subject, I kept getting loads of FileNotFound exceptions within my Windows Event Viewer Application logs. Further analysis using Process Monitor did not produce much good diagnostic information.
I thought it might be a mismatch in .NET Framework version but that doesn’t seem to be the case…
So I decided to create a vanilla Actor project and deploy it to my Stand Alone Cluster. That worked like a Charm but as soon as I added a reference to my .NET Standard Library it started giving me the same errors. Now, when I say ‘reference’ I mean literally reference one of the classes in the .NET Standard library within a method signature of one of the Actors interfaces. This was an a-HAAAAaaaa moment.
After that I decided to reproduce the issue in an isolated project. I created a Service Fabric application, two actors, and two class libraries (one .NET Standard 2.0 and one .NET Framework). I added a simple method signature to make reference to a class within the class libraries.
When I deploy to the Stand Alone Cluster, the Actor that is referencing the .NET Core library gives me the same behavior as my other project.
For each node it gives me an error saying that my code package failed.
The application failure I think stems from the fact that due to the code package failing there are no nodes that can actually deploy the application.
Error event: SourceId='System.FM', Property='State'.
Partition is below target replica or instance count.
fabric:/Application6/Actor2ActorService 3 3 112f7ffd-1070-4686-8016-1c5ed76e4140
(Showing 0 out of 0 replicas. Total available replicas: 0)
Here are all the errors that I get from this issue. God bless Service Fabric. Maybe I missed it in the documentation but the error messages sure don’t make a simple problem like .NET Standard Assembly compatibility easy.
- Unhealthy partitions: 100% (10/10), MaxPercentUnhealthyPartitionsPerService=0%.
- Unhealthy partition: PartitionId=’112f7ffd-1070-4686-8016-1c5ed76e4140’, AggregatedHealthState=’Error’.
- Error event: SourceId=’System.FM’, Property=’State’.
- Partition is below target replica or instance count.
- fabric:/Application6/Actor2ActorService 3 3 112f7ffd-1070-4686-8016-1c5ed76e4140
- (Showing 0 out of 0 replicas. Total available replicas: 0)
My solution was to create a .NET Framework project and link all the classes from .NET Standard library into it then publish a Nuget Package using that. The only trick is how I will be able to call that from my ASP.NET Core WebAPIs… I may have to skip .NET Core all together.