我这里有一个独特的案例。
经过大量的试验和足够的谷歌搜索,我还无法解决这个问题。
我有一组运行时版本为“v2.0.50727”的库(第三方),我必须在我的 WINDOWS SERVICE 应用程序中使用它(这里是键“ Windows Service ”),这需要 .Net v4.0 (v4. 0.30319)。
我已经成功解决了到处描述的混合模式组装错误。
这里最丰富的解决方案之一:
在 .NET 4.0 项目中引用 .NET 2.0 混合模式程序集需要哪些“附加配置”?
安装后的服务,没有启动。(引发通用超时异常。)
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 中删除此配置 - 服务正常启动(显然在运行时中断 - 因为混合模式程序集),而将其保留在配置中不会让它启动。
请指导我。任何帮助将非常感激。
PS:1.到目前为止,我已经尝试了上面stackoverflow链接中指定的所有建议。
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/> </startup>
- 使用 VS 2012、.Net Framework 4.0、Windows 7