【发布时间】:2018-02-19 13:09:49
【问题描述】:
我正在开发一项 Windows 服务。以前它正在启动,我可以进行一些调试,但现在由于TypeInitializationException 而不再是这种情况了。情况如下:
我正在使用 Windows 任务管理器的 Service 选项卡来启动服务。
甚至不到一秒钟,我收到以下错误消息(对话框):
The operation could not be completed.
The service did not respond to the start or control request in a timely fashion.
为什么这是一个问题?
- 服务以
Sleep(10000)开头,因此至少 10 秒(我需要执行“附加到进程”的时间)不会发生任何事情。 - 在注册表中,我已将值 180000 填入或值
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ServicesPipeTimeout,因此在整整 3 分钟之前我不应该出现上述对话框。
我知道我面对TypeInitializationException的原因是我在事件日志中找到了这个作为解释,标签的完整内容如下:
<Data>Application: [Windows-Service].exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException at <Module>._initterm(Void ()*, Void ()*) at <Module>.<CrtImplementationDetails>.LanguageSupport.InitializeNative(<CrtImplementationDetails>.LanguageSupport*) at <Module>.<CrtImplementationDetails>.LanguageSupport._Initialize(<CrtImplementationDetails>.LanguageSupport*) at <Module>.<CrtImplementationDetails>.LanguageSupport.Initialize(<CrtImplementationDetails>.LanguageSupport*) at <Module>..cctor() Exception Info: System.TypeInitializationException</Data>
是否有人知道该异常是关于什么的和/或我如何知道是哪一行代码导致了它?
顺便说一句,我尝试使用 <!-- language: lang-xml --> 的语言支持,但我没有看到典型的 XML 解析。我做错了什么?
在 UKMonkey 评论后添加:
根据 UKMonkey 的建议,同时我发现了哪条线路是造成上述问题的原因,这里是:
output_stream = std::ofstream(output_file);
其中output_file 是相应类的公共属性,在此定义为:
char* output_file;
这对任何人都意味着什么吗?
【问题讨论】:
-
'之前它正在启动,我可以做一些调试' 所以还原;重新测试(因为可能不是您的程序导致了问题),然后比较找出您更改的内容
标签: c++ xml windows-services