在我的 Windows 服务中,我创建了要记录的文件,但现在服务无法运行
Logger.InitLogFile("BridgeServiceLog.txt");
给我这个错误 错误1053:服务没有及时响应启动或控制请求
public BridgeService()
{
InitializeComponent();
Logger.InitLogFile("BridgeServiceLog.txt");
Trace.WriteLine(Logger.logSwitch.TraceInfo, "Trace Started");
this.ServiceName = "BridgeService";
if (!System.Diagnostics.EventLog.SourceExists("BridgeSource"))
{
System.Diagnostics.EventLog.CreateEventSource("BridgeSource", "BridgeLog");
}
_bridgeServiceEventLog.Source = "BridgeSource";
_bridgeServiceEventLog.Log = "BridgeLog";
}
我的 onStart 方法
protected override void OnStart(string[] args)
{
Trace.WriteLineIf(Logger.logSwitch.TraceInfo, "OnStart method Started");
try
{
_bridgeServiceEventLog.WriteEntry("new OnStart");
if (Vytru.Platform.Bridge.Configuration.LicenseValidetor.ValidCountAndTypeDevices())
{
SharedData.InitializeBridge();
// WsInitializeBridge();
}
else
{
this.Stop();
_bridgeServiceEventLog.WriteEntry("LicenseValidetor Error");
}
_bridgeServiceEventLog.WriteEntry("end Start");
}
catch (Exception e)
{
Trace.WriteLineIf(Logger.logSwitch.TraceError, e.Message);
_bridgeServiceEventLog.WriteEntry("error In onstart method " + e.Message);
}
Trace.WriteLineIf(Logger.logSwitch.TraceInfo, "OnStart Ended");
}