【发布时间】:2014-09-23 14:30:02
【问题描述】:
我这里有一个独特的案例。
经过大量的试验和足够的谷歌搜索,我仍然无法解决这个问题。
我有一组运行时版本为“v2.0.50727”的库(第三方),我必须在我的 WINDOWS SERVICE 应用程序中使用它们(这里是键“Windows Service”),这需要 .Net v4.0 (v4.0.30319)。
我已经成功解决了到处描述的混合模式组装错误。
这里最丰富的解决方案来源之一:
安装后的服务,没有启动。 (抛出通用超时异常。)
The MyWindowsService service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
事件查看器中的详细信息(在 windows 日志 > 应用程序下)指定 2 个来源
-
.Net Runtime(详情如下)
应用程序:MyWindowsService.exe 框架版本:v4.0.30319 说明:进程因未处理的异常而终止。 异常信息:System.Configuration.ConfigurationErrorsException 堆: 在 System.Configuration.ClientConfigurationSystem.EnsureInit(System.String) 在 System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String) 在 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String) 在 System.Configuration.ConfigurationManager.get_AppSettings() 在 MyWindowsService..ctor() 在 MyWindowsService.Program.Main()
- 应用程序错误:(详情如下)
错误应用程序名称:MyWindowsService.exe,版本:1.0.0.0,时间戳:0x53da4547 错误模块名称:KERNELBASE.dll,版本:6.1.7601.18409,时间戳:0x53159a86 异常代码:0xe0434352 故障偏移:0x0000c42d 错误进程 ID:0x3814 错误的应用程序启动时间:0x01cfacc646c337dc 错误的应用程序路径:c:\Src\bin\MyWindowsService.exe 错误模块路径:C:\Windows\syswow64\KERNELBASE.dll 报告 ID:8d72e05a-18b9-11e4-a80e-689423ef1889
这里重要的是,如果我从 app.config 中删除此配置 - 服务会正常启动(显然在运行时中断 - 因为混合模式程序集),而将其保留在配置中不会让它启动。
请指导我。 任何帮助将不胜感激。
附注: 1.到目前为止,我已经尝试了上面stackoverflow链接中指定的所有建议。
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/> </startup>
- 使用VS 2012,.Net Framework 4.0,windows 7
【问题讨论】:
-
程序崩溃的异常是否与
<supportedRuntime>元素有关是非常值得怀疑的。它对您的应用程序设置不满意,没有一个体面的异常消息说明原因。在 Main() 方法中订阅 AppDomain.CurrentDomain.UnhandledException 事件,以便获得更好的报告。看起来你已经在这样做了,它需要工作。 -
@HansPassant:我试过你的建议,但没有比这更好的了。
标签: c# .net windows-services mixed-mode app-startup