一个解决方案中的服务和控制台应用程序 [英] A service and a console application in one solution

查看:48
本文介绍了一个解决方案中的服务和控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在构建一个包含两个项目的解决方案:



1。 Windows服务。



Windows服务以此代码开头:



ManagementGroup mg =新管理组(localhost) ;



2.控制台应用程序。



当Windows服务启动时,控制台应用程序必须使用管理来自服务的组连接。如果服务未启动,我的控制台应用程序必须提供错误。错误没有问题,但我如何从其他项目调用代码。



你能给我一个如何做到这一点的例子吗?



亲切的问候,


$ b $bAndré

Hi guys,

I'm building one solution with two projects:

1. Windows Service.

The windows service starts with this code:

ManagementGroup mg = new ManagementGroup("localhost");

2. Console Application.

When the Windows service starts the console application must use the management group connection from the service. If the service doesn't start my console application must give an error. The error is no problem, but how do i call code from the other project.

Can you give me a little example of how to do this?

Kind regards,

André

推荐答案

参见Mark Gravell的解决方案: https://groups.google .com / forum /?hl = en#!topic / microsoft.public.dotnet.languages.csharp / TUXp6lRxy6Q [ ^ ](你可以在我的文章 [ ^ ])。

您可以扩展该可执行文件的入口点以执行任务ñ eed。
See Mark Gravell's solution here: https://groups.google.com/forum/?hl=en#!topic/microsoft.public.dotnet.languages.csharp/TUXp6lRxy6Q[^] (you could find it more clearly in my article[^]).
You can extend the entry point of that executable to perform the task you need.


我已经开发出这种方法。请查看我过去的答案以获得一些关键想法:使用UI配置Windows服务 [ ^ ]。



如果您需要更多帮助,请询问您的后续问题。



-SA
I have develop exactly this approach. Please look at my past answer to get some key ideas: Configure Windows Service with UI[^].

If you need more help with it, please ask your follow-up questions.

—SA


这篇关于一个解决方案中的服务和控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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