Windows服务启动并立即停止 [英] Windows Service Starts and Immediately Stops

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

问题描述

嗨。


我知道我的Windows服务在我的dev

机器上以调试模式运行时工作。

它也适用于我的开发机器上的发布模式。但是,当我将

服务移动到

a生产服务器时,它会立即退出,启动/停止/无需

做错误。


可能出错了什么?


我的OnStart看起来像这样:


protected override void OnStart (string [] args)

{

InitIndexer();

}


和InitIndexer ()是构成

服务的代码的一小段代码。


任何想法?


谢谢。

Hi.

I know my windows service works when i run it in debug mode on my dev
machine.
It also works in release mode on my dev machine. But, when I move the
service to
a production server, it exits immediately with a start/stop/nothing to
do error.

What could be wrong?

My OnStart looks like this:

protected override void OnStart(string[] args)
{
InitIndexer();
}

and InitIndexer() is a lengthly bit of code making up the meat of the
service.

any ideas?

thanks.

推荐答案

1月7日,10:11 * am,pbd22< dush ... @ gmail.comwrote:
On Jan 7, 10:11*am, pbd22 <dush...@gmail.comwrote:

嗨。


我知道我的Windows服务在我的dev上以调试模式运行时工作

机器。

它也适用于我的开发机器上的发布模式。但是,当我将

服务移动到

a生产服务器时,它会立即退出,启动/停止/无需

做错误。


有什么不对吗?

我的OnStart看起来像这样:


* protected override void OnStart(string [] args)

* * * * {

* * * * * * InitIndexer();

* * * * }


和InitIndexer()是一段代码,构成了

服务的代码。


任何想法?


谢谢。
Hi.

I know my windows service works when i run it in debug mode on my dev
machine.
It also works in release mode on my dev machine. But, when I move the
service to
a production server, it exits immediately with a start/stop/nothing to
do error.

What could be wrong?

My OnStart looks like this:

*protected override void OnStart(string[] args)
* * * * {
* * * * * * InitIndexer();
* * * * }

and InitIndexer() is a lengthly bit of code making up the meat of the
service.

any ideas?

thanks.



服务调试可能有点麻烦,因为你不能只附加一个

调试器。因为在你发布应用程序之前你会想要事件记录

无论如何,请记住,现在就把它放进去,然后用它来调试

。然后你可以在你的代码中准确找出你想要的东西和

看看事情的发展方向。


你的日志方法很简单,例如:


private void LogEvent(string LogMessage,EventLogEntryType

LogEntryType)

{

if(!EventLog。 SourceExists(_eventSource))

{

EventLog.CreateEventSource(_eventSource,_logAppName);

}


EventLog MyLog = new EventLog();

MyLog.Source = _eventSource;

MyLog.WriteEntry(LogMessage,LogEntryType);

}

带调用者的


LogEvent(string.Format("服务中的错误:OnStart(){1}",ex.Message ),

EventLogEntryType.Error);


dave

services can be a bit of a pain to debug as you can''t just attach a
debugger. as you''ll want event logging before you release your app
anyway, mind as well just put it in now, and use it for debugging
also. you can then trace out exactly what you want in your code and
see where things go ary.

your log method is simple, something like:

private void LogEvent(string LogMessage, EventLogEntryType
LogEntryType)
{
if (!EventLog.SourceExists(_eventSource))
{
EventLog.CreateEventSource(_eventSource, _logAppName);
}

EventLog MyLog = new EventLog();
MyLog.Source = _eventSource;
MyLog.WriteEntry(LogMessage, LogEntryType);
}

with caller

LogEvent(string.Format("Error in Service:OnStart() {1}", ex.Message),
EventLogEntryType.Error);

dave


谢谢Dave,


那么,代码应该是这样的吗? :


protected override void OnStart(string [] args)

{

try

{

InitIndexer();

}

catch(例外情况)

{

LogEvent(string.Format("

中的错误VBIndexerService:OnStart(){1}",ex.Message),

EventLogEntryType.Error);

}

}
Thanks Dave,

So, the code should look like this? :

protected override void OnStart(string[] args)
{
try
{
InitIndexer();
}
catch(Exception ex)
{
LogEvent(string.Format("Error in
VBIndexerService:OnStart() {1}", ex.Message),
EventLogEntryType.Error);
}
}


确定。


去活动日志并看到所有类型的COM对象访问被拒绝

错误。

似乎我在DEV环境中注册的DLL没有被触发时



将一切都移到生产服务器上(我猜)。


示例:


事件类型:错误

活动来源:我的来源

活动类别:无

活动编号:0

日期:1/7/2008

时间:下午1:29:54

用户:N / A

电脑:我的电脑

描述:

WindowsXYZServer.GetSpace()Ac cess被拒绝了。 (HRESULT的例外情况:

0x80070005(E_ACCESSDENIED))

有关详细信息,请参阅
http://go.microsoft.com/fwlink/events.asp


问题:


如果我在我的DEV系统中将DLL注册为特定路径,请说:​​


C:/x/y/z/library.DLL


然后我将windows服务移动到:


C:/ a / b / c /


并将DLL放入


C:/a/b/c/library.DLL


是否会捏造一切?


开发

系统中DLL文件的路径必须与DLL的路径匹配实时服务器上的文件?


谢谢。
OK.

Went to the event logs and see all sorts of COM object access denied
errors.
Seems the DLLs I registered in the DEV environment are not firing when
I
move everything to the production server (my guess).

Example:

Event Type: Error
Event Source: My Source
Event Category: None
Event ID: 0
Date: 1/7/2008
Time: 1:29:54 PM
User: N/A
Computer: My Computer
Description:
WindowsXYZServer.GetSpace() Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED))

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Question:

If I register a DLL as a certain path in my DEV system, say:

C:/x/y/z/library.DLL

and then I move the windows service to:

C:/a/b/c/

and put the DLLs in

C:/a/b/c/library.DLL

does that fudge up everything?

Must the path of the DLL files in the development
system match the path of the DLL files on the live server?

Thanks.


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

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