Search code examples
c#.net-coreazure-service-fabric

Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0' exception when starting Stateful Service


I have created a new Service Fabric application in Visual Studio 2017 (version 15.7.1) and added a new service using the .Net Core 2.0 Stateful Service template.

When I try to run the service it fails to start correctly and I can see the following exception in the Diagnostic Events:

Description='Replica had multiple failures during open on _Node_0. API call: IStatefulServiceReplica.ChangeRole(P);

Error = System.IO.FileNotFoundException (-2147024894) Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.


Solution

  • I fixed this by installing the Nuget package System.ServiceModel.Primitives:

    PM> Install-Package System.ServiceModel.Primitives