启动有状态服务时无法加载文件或程序集 'System.ServiceModel, Version=4.0.0.0' 异常
Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0' exception when starting Stateful Service
我在 Visual Studio 2017(版本 15.7.1)中创建了一个新的 Service Fabric 应用程序,并使用 .Net Core 2.0 有状态服务添加了一个新服务模板.
当我尝试 运行 服务时,它无法正确启动,我可以在诊断事件中看到以下异常:
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.
我通过安装 Nuget 包解决了这个问题 System.ServiceModel.Primitives:
PM> Install-Package System.ServiceModel.Primitives
Windows11 更新后可能有用的答案。
在我的例子中,在更新 Windows 11 之后,由于这个错误,应用程序无法运行。我遇到错误无法加载文件或程序集 System.ServiceModel,版本 3.0.0.0.
经过长时间的研究,我卸载了 .net 框架,re-installed 它成功了。
为此,我使用了 programs/Uninstall 和 program/Add 删除 windows 功能。
取消选中所有 .net framework 案例并单击“确定”按钮。
卸载过程结束后,我检查了相同的情况,然后单击“确定”按钮。
宾果!
我在 Visual Studio 2017(版本 15.7.1)中创建了一个新的 Service Fabric 应用程序,并使用 .Net Core 2.0 有状态服务添加了一个新服务模板.
当我尝试 运行 服务时,它无法正确启动,我可以在诊断事件中看到以下异常:
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.
我通过安装 Nuget 包解决了这个问题 System.ServiceModel.Primitives:
PM> Install-Package System.ServiceModel.Primitives
Windows11 更新后可能有用的答案。
在我的例子中,在更新 Windows 11 之后,由于这个错误,应用程序无法运行。我遇到错误无法加载文件或程序集 System.ServiceModel,版本 3.0.0.0.
经过长时间的研究,我卸载了 .net 框架,re-installed 它成功了。
为此,我使用了 programs/Uninstall 和 program/Add 删除 windows 功能。
取消选中所有 .net framework 案例并单击“确定”按钮。 卸载过程结束后,我检查了相同的情况,然后单击“确定”按钮。
宾果!