C# 中的 Windows 服务 - 崩溃/错误
我们有一个用 C# 编写的 Windows 服务。运行大约5-6小时后就崩溃了。 我们的 C# Windows 服务调用非托管代码,这是一个 COM 组件。
我从事件查看器获得的唯一错误信息是:
故障应用程序 application.exe,版本 2.2.2.0,标记 45ed8d14, 错误模块 comcomponent.dll,版本 5.2.3790.3959,标记 45d70ad8,调试? 0,故障地址0x0000bee7。
有没有办法通过在不同进程中运行非托管代码来保持 Windows 服务活动/连续运行?
截至目前,我们已尝试使用 AppDomain
作为不同的进程,但未能解决此问题。
请提出合适的解决方案。
We have a Windows service written in C#. it is crashing after running for sometime about 5-6 hours.
Our C# Windows service calls Un-Managed code which is a COM component.
The only error information I get from Event Viewer is:
Faulting application application.exe, version 2.2.2.0, stamp 45ed8d14,
faulting module comcomponent.dll, version 5.2.3790.3959, stamp 45d70ad8, debug?
0, fault address 0x0000bee7.
Is there any way to keep windows service alive/running continuously by running un-managed code in different process?
As of now we've tried AppDomain
as different process but it failed to overcome this issue.
Please suggest a suitable solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
即使您启动一个新的 AppDomain,它仍然是相同的过程。
由于您已经在使用 COM,我认为 .NET Enterprise Services 会成为您的最佳解决方案。在许多其他功能中,企业服务可以在不同的进程中托管您的 COM 对象。
Even if you spin up a new AppDomain, it's still the same process.
Since you are already using COM, I think .NET Enterprise Services would be an optimal solution for you. Among many other features, Enterprise Services can host your COM object in a different process.
除了尝试使代码尽可能健壮之外,您可能还需要查看 Service Protector 。当您的关键任务服务因任何原因崩溃、挂起或停止时,它会自动重新启动它,并向您发送电子邮件,让您知道发生了什么。利用 30 天免费试用,确保它将帮助解决您的问题。
祝你好运!
In addition to trying to make your code as robust as possible, you may want to take a look at Service Protector. It will automatically restart your mission-critical service when it crashes, hangs or stops for whatever reason, and will send you email to let you know what happened. Take advantage of the free 30-day trial to ensure that it will help solve your problem.
Good luck!