Windows服务错误1053:服务未及时响应启动或控制请求

时间:2013-12-04 09:37:50

标签: .net vb.net windows-services

我正在使用Windows 7旗舰版,启动Windows服务时收到此错误

错误1053:服务未及时响应启动或控制请求。

Description: The process was terminated due to an unhandled exception.
Exception Info: System.Security.SecurityException
Stack:
   at System.Diagnostics.EventLog.FindSourceRegistration(System.String, System.String, Boolean, Boolean)
   at System.Diagnostics.EventLog.SourceExists(System.String, System.String, Boolean)
   at System.Diagnostics.EventLog.SourceExists(System.String)
   at GateePrinterMonitor.Service1..ctor()
   at GateePrinterMonitor.Service1.Main()

我正在使用LocalService帐户知道如何解决此问题?

Public Class Service1

    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
        EventLog1.WriteEntry("In OnStart")
    End Sub

    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
        EventLog1.WriteEntry("In OnStop.")
    End Sub

    Public Sub New()

        ' This call is required by the designer.
        'InitializeComponent()
        MyBase.New()
        InitializeComponent()
        If Not System.Diagnostics.EventLog.SourceExists("MySource") Then
            System.Diagnostics.EventLog.CreateEventSource("MySource",
            "MyNewLog")
        End If
        EventLog1.Source = "MySource"
        EventLog1.Log = "MyNewLog"

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
End Class

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用LocalSystem?在我看来,LocalService没有访问事件日志的权限 - 它是一个相对没有特权的用户。