'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 1:[1]
I fixed this by installing the Nuget package System.ServiceModel.Primitives:
PM> Install-Package System.ServiceModel.Primitives
Solution 2:[2]
An answer which may be useful after a Windows 11 update.
In my case, after an update of Windows 11, the application wasn't working because of this error. I had the error Could not load file or assembly System.ServiceModel, version 3.0.0.0.
After long research, I uninstalled the .net framework and re-installed it and it worked.
For this, I used the programs/Uninstall a program/Add remove windows features.
Unchecked all .net framework cases and click on the Okay button. After the uninstall process, I checked the same cases and click on the Okay button.
Bingo!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | RagtimeWilly |
Solution 2 | Coskun Ozogul |