System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed.

项目代码如下

ServiceController service = new ServiceController("ModbusAgent");
service.Stop();
TimeSpan timeout = new TimeSpan(50000);
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout); 

按照Stackoverflow:Time out has expired and the operation has not been completed in Service manager的说法,不要对其设置服务超时

于是代码改成:

ServiceController service = new ServiceController("ModbusAgent");
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped); 

问题解决

原文地址:https://www.cnblogs.com/passedbylove/p/9045595.html

时间: 2024-11-23 00:32:42

System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed.的相关文章

System.ServiceProcess与System.Configuration.Install命名空间的介绍

System.ServiceProcess 命名空间提供用于实现.安装和控制 Windows 服务应用程序的类.服务是长期运行的可执行文件,其运行没有用户界面 System.ServiceProcess 命名空间 System.ServiceProcess 命名空间下10个类的列表 windows 服务开发和windows install开发 C# VS 2010创建.安装.调试 windows服务(windows service) C#中的DllImport使用方法 关于dllimport的使

解决报错"Your security system have blocked an application with expired or not yet valid certificate from running"

方法如下: Go to Control Panel Java in the Security tab click the "Edit Site List-" button click Add button insert the URL of the website that you want access in (URL should begin with http:// or https://) click Add button click OK button click OK bu

启动MYSQL 57 报错“The service MYSQL57 failed the most recent........等”的问题解决方式!

每天开机之后,启动MYSQL Notifier就报错,第一次出现重启电脑后解决,后面的几天老是出现,重启电脑好几次都没有解决,感觉很烦人,一定要搞定这个问题找到原因,于是有了下文....... 启动MYSQL 57报错信息"The service MYSQL57 failed the most recent status change request with the message time out has expired and the operation has not been comp

.Net 指定时间段内定时执行的Windows服务(System.Threading.Thread)

创建一个Windows服务项目:解决方案(右击)——> 添加 ——> 新建项目——>项目类型选择Windows——>模板选择Windows服务 ,如图: 编写Windows服务程序创建后会生成两个文件 Program.cs 和 Service1.cs(我已重命名为MyService.cs),编写服务内容:具体服务代码: 1 using System; 2 using System.Configuration; 3 using System.ServiceProcess; 4 usi

C#中System.ServiceProgress报错

场景 在C#中检索本地计算机所有服务时,使用 System.ServiceProcess.ServiceController[] services = System.ServiceProcess.ServiceController.GetServices(); 报错 注: 博客主页: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获取编程相关电子书.教程推送与免费下载. 实现 在程序中-引用-添加引用--框架-System.Serv

NotSupportedException-无法将类型“System.DateTime”强制转换为类型“System.Object”

几张图就可以说明一切 2015-03-29 21:54:09,206 [77] ERROR log - System.NotSupportedException: 无法将类型“System.DateTime”强制转换为类型“System.Object”.LINQ to Entities 仅支持强制转换 EDM 基元或枚举类型. 在 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.ValidateAndAdjustCastType

Parallelized coherent read and writeback transaction processing system for use in a packet switched cache coherent multiprocessor system

A multiprocessor computer system is provided having a multiplicity of sub-systems and a main memory coupled to a system controller. An interconnect module, interconnects the main memory and sub-systems in accordance with interconnect control signals

Residential Gateway System for Home Network Service

Disclosed herein is a Residential Gateway (RG) system for home network service. The RG system receives various supplementary services through a Home Network Serving Node (HNSN) that provides home network service. The system includes an Open Service G

Adaptive partitioning scheduler for multiprocessing system

A symmetric multiprocessing system includes multiple processing units and corresponding instances of an adaptive partition processing scheduler. Each instance of the adaptive partition processing scheduler selectively allocates the respective process