在同一个应用程序中启动两个Windows服务

在同一个应用程序中启动两个Windows服务,第1张

概述在同一个应用程序启动两个Windows服务

我有以下问题。

我有两个windows服务应用程序启动在同一个应用程序(WPF),都已经安装。 但是当我必须“启动”它们(ServiceController.Start())时,只有先启动的服务保持打开,另一个返回消息:

错误1053:该服务没有及时响应启动或控制请求

这是我的代码来启动它们:

如何合并两个列表的值

与Multi-touch Manipulations相关的未公开的.NET代码引发exception

如何在windows中以兼容模式启动应用程序会影响应用程序,我该如何检测它?

用于.NET的可编程RAM磁盘API?

System.Speech语音合成器的奇怪问题

//*TS_TimeOut timespan has 1 hour private voID InitServiceOne() { ServiceController SControllerServiceOne = new ServiceController("ServiceOne",Environment.Machinename); SControllerServiceOne.Start(); SControllerServiceOne.WaitForStatus(ServiceControllerStatus.Running,TS_TimeOut); } private voID InitServiceTwo() { ServiceController SControllerServiceTwo = new ServiceController("ServiceTwo",Environment.Machinename); SControllerServiceTwo.Start(); SControllerServiceTwo.WaitForStatus(ServiceControllerStatus.Running,TS_TimeOut); }

这是我用来安装它们的代码:

private voID InstallServiceOne(string strServiceOnePath) { ServiceProcessInstaller ProcessServiceServiceOne = new ServiceProcessInstaller(); ServiceInstaller ServiceInstallerOne = new ServiceInstaller(); InstallContext Context = new System.Configuration.Install.InstallContext(); String path = String.Format("/assemblypath={0}",strServiceOnePath)); String[] cmdline = { path }; Context = new System.Configuration.Install.InstallContext("",cmdline); ServiceInstallerOne.Context = Context; ServiceInstallerOne.displayname = "ServiceOne"; ServiceInstallerOne.Description = "ServiceOne"; ServiceInstallerOne.Servicename = "ServiceOne"; ServiceInstallerOne.StartType = ServiceStartMode.automatic; ServiceInstallerOne.Parent = ProcessServiceServiceOne; System.Collections.Specialized.ListDictionary stateServiceOne = new System.Collections.Specialized.ListDictionary(); ServiceInstallerObjIntegracao.Install(stateServiceOne); } private voID InstallServiceTwo(string strServiceTwoPath) { ServiceProcessInstaller ProcessServiceServiceTwo new ServiceProcessInstaller(); ServiceInstaller ServiceInstallerTwo = new ServiceInstaller(); InstallContext Context = new System.Configuration.Install.InstallContext(); String path = String.Format("/assemblypath={0}",strServiceTwoPath); String[] cmdline = { path }; Context = new System.Configuration.Install.InstallContext("",cmdline); ServiceInstallerTwo.Context = Context; ServiceInstallerTwo.displayname = "ServiceTwo"; ServiceInstallerTwo.Description = "ServiceTwo"; ServiceInstallerTwo.Servicename = "ServiceTwo"; ServiceInstallerTwo.StartType = ServiceStartMode.automatic; ServiceInstallerTwo.Parent = ProcessServiceServiceTwo; System.Collections.Specialized.ListDictionary stateServiceTwo = new System.Collections.Specialized.ListDictionary(); ServiceInstallerObjBRMonitoring.Install(stateServiceTwo); }

这是我在stackoverflow社区的第一个问题,英文不是我的母语。 如果我犯了任何错误,我很抱歉。

为什么Process.Start会意外返回false

如何启用/禁用防火墙?

如何将拼写检查程序添加到Richtext框?

VB 6 / .NET interop最近被windows更新破坏了吗?

如何为windows上的任务栏创build工具栏?

问题已经解决了!

我只是不得不从调试更改为发布和安装发行.exe,现在两个服务正在运行和工作没有任何问题。

总结

以上是内存溢出为你收集整理的在同一个应用程序中启动两个Windows服务全部内容,希望文章能够帮你解决在同一个应用程序中启动两个Windows服务所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1285137.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存