我正在尝试运行Visual Basic服务。
安装和卸载该服务工作正常,但是,当试图通过任务管理器启动该服务时,会显示以下错误消息:
Unable to start service
The operation could not be completed.
The service did not respond to the start or control request in a timely fashion.
在事件查看器中,会记录与此相关的以下错误消息:
A timeout was reached (30000 milliseconds) while waiting for the ABC service to connect.
The ABC service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
尝试使用以下命令通过cmd启动服务:
net start "ABC"
...导致以下错误消息:
The service is not responding to the control function.
More help is available by typing NET HELPMSG 2186.
毫无帮助的是,键入“NET HELPMSG 2186”只会重复错误消息的前半部分:
The service is not responding to the control function.
我看过该服务的源代码,但对其架构不太熟悉。然而,我可以确定一些我认为可能与该服务相关的功能,即:
OnStart(String())
OnStop()
New()
从目前为止我从相关线程中收集到的信息来看,错误消息可能意味着服务没有服务控制函数要处理的适当功能。这里会是这样吗?
如果没有,你会建议用什么方法来调试它?
其他信息
以下是OnStart方法的外观:
Protected Overrides Sub OnStart(ByVal args() As String)
Dim log As ILogger = CommonObjectFactory.instance.buildLogger(LogName.ABCDSys).open("OnStart")
Dim oCallback As Threading.TimerCallback = Nothing
Try
Dim numTimeDuration As Integer = 30000
Try
'numTimeDuration = Convert.ToInt32(ABCDA.ABCProperties.Instance.GetValue("DTimer", "DSys", "5000"))
Dim config As IDServiceConfiguration = CommonObjectFactory.instance.buildConfigurationFactory().buildDSConfiguration()
numTimeDuration = config.DTimer
Catch ex As Exception
log.error(ex)
End Try
log.info("Setting up a " & numTimeDuration / 1000 & " second timer")
oCallback = New Threading.TimerCallback(AddressOf TimerEvent)
_timer = New System.Threading.Timer(oCallback, Nothing, numTimeDuration, numTimeDuration)
Catch ex As Exception
log.error(ex)
End Try
log.close()
log = Nothing
End Sub
据我所知,这项服务应该每30秒检查一次文档,从我在代码中看到的情况来看,这就是应该发生的事情。
然而,当试图启动服务时,它崩溃了
立即
。30秒后不会出现,但会立即出现,即使事件日志中的错误消息显示“已达到超时(30000毫秒)”。事实上,我以前使用过这个服务,30秒后它崩溃了,但在所有这些情况下,它在其中一个日志中写了一条有用的错误消息。现在,甚至连日志都没有创建。
我想知道日志记录是否有问题。那就是这条线,对吗?
Dim log As ILogger = CommonObjectFactory.instance.buildLogger(LogName.ABCDSys).open("OnStart")
对我来说,调试这个的最佳方式是什么?由于公司的工作流程,我无法在我的开发机器上测试,但必须先通过TeamCity运行整个代码,然后再在另一台机器上测试,所以我不确定如何处理调试。考虑到服务立即崩溃,我甚至没有时间给它添加调试器。有没有办法将其连接到调试器上启动?