2017-03-20 48 views
0

問題:在我的開發機器上,一切正常。然而,當我的可執行文件複製到服務器上,我的程序沒有啓動程序無法啓動;事件查看器日誌ConfigurationsErrorException

什麼我迄今所做的:我檢查事件查看器和錯誤堆棧看起來是這樣的:

Application: Project.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 

Exception Info: System.Configuration.ConfigurationErrorsException 
Stack: 

    at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String) 
    at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String) 
    at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String) 
    at System.Configuration.ConfigurationManager.GetSection(System.String) 
    at System.Configuration.ConfigurationManager.get_ConnectionStrings() 
    at Project.BaseService..ctor() 
    at Project.Service..ctor() 
    at Project.Program.Main() 

我在網上查了一下,並且大多數時候,這個錯誤是由.config文件中一些錯誤的configSections產生的。爲了確保不是這種情況,我讓app.config和.exe.config文件都保持清潔(只有部分在那裏),但我的程序仍然無法工作。

然後,我從失敗的進程生成一個轉儲文件,這裏是奇怪的事情:我調用ConfigurationManager.ConnectionStrings時引發的異常是「配置系統無法初始化」,與「The'添加257行第6行的開始標記與'connectionManagement'的結束標記不匹配。第258行第3行。「內部異常。我仔細檢查了我的整個項目,並且沒有任何地方提到「connectionManagement」!我甚至試圖檢查AppDomain.CurrentDomain.SetupInformation.ConfigurationFile的值,它表明正確的配置文件。

通過修復此連接管理問題我可能會運行我的應用程序,但是你們是否知道這可能來自哪裏?

+1

看起來像你有不匹配的XML標籤。像''或''。要麼丟失了或嵌套錯誤。 – ps2goat

+1

在整個解決方案中進行全文搜索,所有文件類型爲「connectionManagement」。它可能會在.config文件中找到匹配項。如果明顯可以修復,或者發佈相關文件的相關部分。 – dlatikay

回答

0

問題出現在服務器上的machine.config文件中。改變它解決了問題!