【发布时间】:2020-03-20 21:26:43
【问题描述】:
我们在服务器上遇到错误,我们的服务在服务器中自动停止。 随机应用程序在大约 1 小时内崩溃,错误如下 -
错误的应用程序名称:Chubb.Studio.Event.Processor.exe,版本: 0.0.0.0,时间戳:0x5c0ab1b7 错误模块名称:KERNELBASE.dll,版本:6.3.9600.19425,时间戳:0x5d26b6e9 异常代码: 0xc0000005 故障偏移量:0x0000000000001556 故障进程 ID: 0x115c 故障应用程序启动时间:0x01d5a35fd202f96d 故障 申请途径: E:\WindowsService\DevInt\Chubb.Studio.EventProcessor\Chubb.Studio.Event.Processor.exe 错误模块路径:C:\Windows\system32\KERNELBASE.dll 报告 ID: 762c15d4-0f5b-11ea-8120-005056a27597 故障包全名: 错误的包相关应用程序 ID:
我们的代码看起来像 -
protected override void OnStarted()
{
//IntializeEventsExecution();
Task task = Task.Factory.StartNew(() => IntializeEventsExecution());
base.OnStarted();
}
public void IntializeEventsExecution()
{
StartEvents();
}
public void StartEvents()
{
var eventList = GetEventTopics();
Parallel.ForEach(eventList,
new ParallelOptions { MaxDegreeOfParallelism = eventList.Count },
(item, state, index) =>
{
StartProcessingEvent(eventList[(int)index]);
});
}
/// <summary>
///
/// </summary>
/// <param name="index"></param>
public void StartProcessingEvent(EventTopic topic)
{
try
{
Task task = Task.Factory.StartNew(() => ExecuteProcessingEvent(topic));
task.Wait();
}
catch (Exception)
{
}
finally
{
new _processingDelegate(StartProcessingEvent).Invoke(topic);
}
}
【问题讨论】:
-
我认为您需要做更多的工作才能让这里的任何人提供帮助。 Windows 服务可能很难调试,因为您并不总是得到有用的错误。您将需要添加大量具有非常好的日志记录的 try-catch,以便您可以准确找出服务失败的原因。
-
0xC0000005 是 STATUS_ACCESS_VIOLATION 这意味着某些代码正在读取或写入不允许的内存。
标签: c# windows-services