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

RagtimeWilly picture RagtimeWilly · Jun 7, 2018 · Viewed 10.9k times · Source

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.

Answer

RagtimeWilly picture RagtimeWilly · Jun 7, 2018

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

PM> Install-Package System.ServiceModel.Primitives