Windows 服务启动然后停止

发布于 2024-08-13 21:13:43 字数 820 浏览 3 评论 0原文

我有一个从已故开发人员那里继承的 Windows 服务。 Windows 服务在 QA 环境中运行良好。当我安装该服务并在本地运行它时,我收到此错误:

服务无法启动。 System.InvalidOperationException:请求的性能计数器不是自定义计数器,它必须初始化为只读。

这是代码:

ExternalDataExchangeService exchangeService = new ExternalDataExchangeService();
            workflowRuntime.AddService(exchangeService);
            workflowRuntime.AddService(new SqlTrackingService(AppContext.SqlConnectionImportLog));
            ChallengerWorkflowService challengerWorkflowService = new ChallengerWorkflowService();
            challengerWorkflowService.SendDataEvent += new EventHandler<SendDataEventArgs>(challengerWorkflowService_SendDataEvent);
            workflowRuntime.AddService(challengerWorkflowService);
            workflowRuntime.StartRuntime(); <---- Exception is thrown here.

I have a Windows Service that I inherited from a departed developer. The Windows Service is running just fine in the QA environment. When I install the service and run it locally, I receive this error:

Service cannot be started. System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.

Here is the code:

ExternalDataExchangeService exchangeService = new ExternalDataExchangeService();
            workflowRuntime.AddService(exchangeService);
            workflowRuntime.AddService(new SqlTrackingService(AppContext.SqlConnectionImportLog));
            ChallengerWorkflowService challengerWorkflowService = new ChallengerWorkflowService();
            challengerWorkflowService.SendDataEvent += new EventHandler<SendDataEventArgs>(challengerWorkflowService_SendDataEvent);
            workflowRuntime.AddService(challengerWorkflowService);
            workflowRuntime.StartRuntime(); <---- Exception is thrown here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转瞬即逝 2024-08-20 21:13:43

检查安装程序代码。通常,您会发现计数器是在安装中创建的(将在客户端站点上的管理员权限下运行),然后代码使用它们,就好像它们存在一样 - 但不会尝试创建它们,因为它们不希望拥有权限。

如果您只是获取源代码然后尝试运行它,则计数器/计数器类不存在,因此您会立即失败。 (或者检查计数器是否存在/您是否有本地管理员,如果他们编写了在服务中创建它的代码。)

之前见过它,所以提到过。

Check for installer code. Often you will find counters are created within an installation (which is going to of been run under admin privledges on client site) and the code then uses them as though they exist - but will not try create them because they do not expect to have the permissions.

If you just get the source and then try run it, the counters / counter classes do not exist so you fall over immediately. (Alternatively check whether the counter exists / you have local admin if they wrote the code to create it in the service.)

Seen it before so mentioned it.

ゞ记忆︶ㄣ 2024-08-20 21:13:43

附加调试器并在 InvalidOperationException 上中断(第一次机会,即抛出时)?

Attach Debugger and break on InvalidOperationException (first-chance, i.e. when thrown)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文