簡體   English   中英

Windows服務無法啟動,混合模式組裝問題

[英]Windows service fails start , Mixed Mode Assembly issue

我這里有一個獨特的案例。

經過大量的試驗和足夠的Google搜索,我仍然無法解決此問題。

我有一組運行時版本為'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.

Event Viewer中的詳細信息(在Windows日志> Application下)指定2個來源

  1. .Net運行時(詳細信息如下)

    應用程序: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()

    1. 應用程序錯誤:(詳細信息如下)

    錯誤的應用程序名稱: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>
  1. 使用VS 2012,.Net Framework 4.0,Windows 7

確定您的服務為何無法啟動的一種方法是將調試器連接到該服務。

由於調試服務需要:

  1. 從服務控制管理器啟動服務
  2. 使用VS中的“調試到進程的附加選項”

由於要連接到OnStart方法,因此需要添加Thread.Sleep(5000); 從服務控制管理器啟動服務后,您有5秒鍾的時間將調試器連接到服務。 在sleep語句之后設置一個斷點。

鑒於您是.NET運行時錯誤,您可能永遠也不會接觸到breakpoing,因為它似乎在加載時遇到了麻煩。

您是否嘗試過創建一個使用相同第三方庫的簡單應用程序來驗證app.config文件的正確設置?

嘗試使用以下內容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" />
  <supportedRuntime version="v2.0.50727" />
 </startup>
</configuration>

我在這里找到此信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM