使用C#中的ServiceController停止并启动服务给定的错误helpp !!! [英] Using the ServiceController in C# to stop and start a service its given error helpp!!!

查看:158
本文介绍了使用C#中的ServiceController停止并启动服务给定的错误helpp !!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ServiceController myService = new ServiceController();
            myService.ServiceName = "ImapiService";
            string svcStatus = myService.Status.ToString();
                if (svcStatus == "Running"){
                    myService.Stop();
                    myService.Refresh();

}
 string svcStatu = myService.Status.ToString();
                if (svcStatu == "Stopped"){
                    myService.Start();
                    myService.Refresh();
}







当我把第一个字符串的断点并继续步一步这个代码是有效的但是当我没有把任何断点代码都给出错误的原因??你能帮助我吗?




When I put the break point of the first string and continue to step by step this code is works but when I didn't put the any break point code will be given an error why??..Can you help me?

推荐答案

这篇关于使用C#中的ServiceController停止并启动服务给定的错误helpp !!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆