2017-04-08 105 views
0

我開發C#的小型應用程序中,我使用的是SQL Server數據庫,但是當我運行我的應用程序我得到這個錯誤:C#WinForm應用程序

An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll

Additional information: Configuration system failed to initialize

誰能幫我解決這個錯誤?

The code of my save button shown in this image where exception error occurred和 我的app.config。文件是:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
    <connectionstring> 
    <add name="dbx" connectionstring="Data Source=JAWADKHAN-PC;Initial Catalog=jawad;Integrated Security=True" Providername="System.Data.SQLClient"> 
    </add> 
     </connectionstring> 
</configuration> 
+0

請向我們展示您的'app.config'文件!顯然**配置系統**有問題(因爲異常消息明確指出) –

+0

應用程序無法加載配置區段,因此在這裏發佈您的app.config肯定會有所幫助。 –

+0

請用相關的保存代碼[編輯]你的問題,而不是鏈接到圖像。 –

回答

0

檢查您的app.config文件。 在配置部分之後添加configSections。像 更換順序:

<configuration> 
    <configSections> 
     .... 
    </configsections> 
    . 
    . 

如果這不能解決你的問題,然後張貼app.config文件進行審查。