記一次windows服務無法安裝問題

windows服務開發完成以後,開始安裝,提示服務已停止,即無法安裝,查看事件查看器,有如下報錯:

應用程序: xxx.exe
Framework 版本: v4.0.30319
說明: 由於未經處理的異常,進程終止。
異常信息: System.Configuration.ConfigurationErrorsException
在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean)
在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(System.Configuration.ConfigurationSchemaErrors)
在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
在 System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)

異常信息: 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()
在 xxx..cctor()

異常信息: System.TypeInitializationException
在 xxx.Main(System.String[])

解決方法:

<configSections>元素一定要作爲<configuration>中的第一個元素!

微軟官網文檔:https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-1.1/aa903350(v=vs.71)

<configSections> Element

If this element is in a configuration file, it must be the first child element of the <configuration> element.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章