取消Windows服务启动 [英] Canceling Windows Service Start

查看:86
本文介绍了取消Windows服务启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用C#编写了一个Windows服务,但我似乎无法弄清楚如何取消或阻止该服务在某些条件下启动。

例如,在OnStart中我读了一些配置设置,如果

任何东西都是空的,或者是无效的(例如DB DataSource字符串或

缺少diredtory, etccc)我不想让服务开始。那么我怎么取消b $ b取消启动呢?

I''ve written a Windows Service using C#, but I cannot seem to figure out how
to cancel or prevent the service from starting under certain conditions.
For example, in the OnStart I read in some configuration settings, and if
anything is either empty, or invalid (such as a DB DataSource string or a
missing diredtory, etccc) I don''t want the servie to start. So how would I
cancel the start up?

推荐答案

任何人都有答案吗?

" JSheble" < JS ************ @ logicor.com>在消息中写道

news:ee ************** @ tk2msftngp13.phx.gbl ...
Anyone have an answer?

"JSheble" <js************@logicor.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
我写的使用C#的Windows服务,但我似乎无法弄清楚如何取消或阻止服务在某些条件下启动。例如,在OnStart中我读了一些配置
设置,如果有什么是空的,或者是无效的(例如DB
DataSource字符串或缺少diredtory,etccc)我不想要服务
开始。那么如何取消启动呢?
I''ve written a Windows Service using C#, but I cannot seem to figure out
how to cancel or prevent the service from starting under certain
conditions. For example, in the OnStart I read in some configuration
settings, and if anything is either empty, or invalid (such as a DB
DataSource string or a missing diredtory, etccc) I don''t want the servie
to start. So how would I cancel the start up?





我对此没有很好的了解。但据我所知,你不能在服务中启动或停止服务。这必须通过写一个

服务控制器。
Hi,
I dont have a very good knowledge on this. But from what I know u cannot
start or stop a servce within a service. This has to be done by a writing a
Service Controller.
读取一些配置设置,如果
任何内容为空或无效(例如DB DataSource字符串或
缺少diredtory,etccc)
以上部分必须由Controller完成,然后服务启动

。 />
请阅读有关监控MSDN中Windows服务的更多信息


" JSheble"写道:

我用C#写了一个Windows服务,但我似乎无法弄清楚如何取消或阻止服务在某些条件下启动。
对于例如,在OnStart中我读了一些配置设置,如果
任何内容为空或无效(例如DB DataSource字符串或
缺少diredtory,etccc)我不想要服务开始。那我怎么取消启动呢?
"read in some configuration settings, and if
anything is either empty, or invalid (such as a DB DataSource string or a
missing diredtory, etccc) The above portion has to be done by the Controller and then the service has
to be started.
PLease read more about monitoring windows services in MSDN

"JSheble" wrote:
I''ve written a Windows Service using C#, but I cannot seem to figure out how
to cancel or prevent the service from starting under certain conditions.
For example, in the OnStart I read in some configuration settings, and if
anything is either empty, or invalid (such as a DB DataSource string or a
missing diredtory, etccc) I don''t want the servie to start. So how would I
cancel the start up?



我不是在谈论监控应用程序,我在说话除非满足某些条件,否则我不希望

服务本身启动。如果他们试图启动服务,那么这些条件就会失败,那么服务器就不应该b
启动。服务如何不允许自己启动?


" Ravi" <太阳神** @ discussions.microsoft.com>在消息中写道

新闻:DD ********************************** @ microsof t.com ...
I am not talking about a monitoring app, I''m talking I don''t want the
service itself to start unless certain conditions are met. If they try to
start the service, and those conditions fail, then the servie should not
start. How does the service not allow itself to be started?

"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...

我对此没有很好的了解。但据我所知,你无法启动或停止服务中的服务。这必须通过写一个
服务控制器。
Hi,
I dont have a very good knowledge on this. But from what I know u cannot
start or stop a servce within a service. This has to be done by a writing
a
Service Controller.
读取一些配置设置,如果
任何内容为空或无效(例如DB DataSource字符串或
缺少diredtory,etccc)
"read in some configuration settings, and if
anything is either empty, or invalid (such as a DB DataSource string or a
missing diredtory, etccc)


以上部分必须由Controller完成,然后服务
已经
开始。
请阅读有关在MSDN中监控Windows服务的更多信息

JSheble写道:


The above portion has to be done by the Controller and then the service
has
to be started.
PLease read more about monitoring windows services in MSDN

"JSheble" wrote:

我用C#编写了一个Windows服务,但我似乎无法弄明如何取消或阻止服务启动某些条件。
例如,在OnStart中我读了一些配置设置,如果
任何内容都是空的或无效的(例如DB DataSource字符串或
缺少diredtory,etccc我不想让服务开始。那么我将如何取消启动呢?
I''ve written a Windows Service using C#, but I cannot seem to figure out
how
to cancel or prevent the service from starting under certain conditions.
For example, in the OnStart I read in some configuration settings, and if
anything is either empty, or invalid (such as a DB DataSource string or a
missing diredtory, etccc) I don''t want the servie to start. So how would
I
cancel the start up?



这篇关于取消Windows服务启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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