2009-08-21 65 views
6

自從刪除原始的settings.settings文件以來,我有無盡的問題讓設置正常運行。我收到「配置系統無法初始化」錯誤的get或set方法。有任何想法嗎?謝謝。訪問settings.settings時出現「配置系統初始化失敗」

public static Settings Default { 
     get { 
      return defaultInstance; 
     } 
    } 

    [global::System.Configuration.UserScopedSettingAttribute()] 
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
    [global::System.Configuration.DefaultSettingValueAttribute("Keywords.log")] 
    public string KeywordsLog { 
     get { 
      return ((string)(this["KeywordsLog"])); 
     } 
     set { 
      this["KeywordsLog"] = value; 
     } 
    } 

問題是位於Settings.Designer.cs

阿德里安·班克斯,我怕我不知道如何進一步調試?它已經打破了錯誤。如果以任何方式提供幫助,給出的框的標題是「ConfigurationErrorsException」。

我很抱歉,我沒有意識到你可以在VS中看到更多細節。

System.Configuration.ConfigurationErrorsException was unhandled 
    Message="Configuration system failed to initialize" 
    Source="System.Configuration" 
    BareMessage="Configuration system failed to initialize" 
    Line=0 
    StackTrace: 
     at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey) 
     at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName) 
     at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.RefreshConfig(String sectionName) 
     at System.Configuration.ConfigurationManager.RefreshSection(String sectionName) 
     at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped) 
     at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties) 
     at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider) 
     at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) 
     at System.Configuration.SettingsBase.get_Item(String propertyName) 
     at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName) 
     at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName) 
     at READOO.Properties.Settings.get_KeywordsLog() in C:\Users\USER\Documents\Visual Studio 2008\Projects\READOO\READOO\Properties\Settings.Designer.cs:line 31 
     at READOO.SettingsWindow..ctor() in C:\Users\USER\Documents\Visual Studio 2008\Projects\READOO\READOO\SettingsWindow.cs:line 19 
     at READOO.WelcomeWindow.Settings_Click(Object sender, EventArgs e) in C:\Users\user\Documents\Visual Studio 2008\Projects\READOO\READOO\WelcomeWindow.cs:line 23 
     at System.Windows.Forms.Control.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
     at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
     at System.Windows.Forms.Button.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
     at READOO.Program.Main() in C:\Users\USER\Documents\Visual Studio 2008\Projects\READOO\READOO\Program.cs:line 18 
     at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
     at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: System.Configuration.ConfigurationErrorsException 
     Message="Section or group name 'READOO.Properties.Settings' is already defined. This can not be defined multiple times. (C:\\Users\\USER\\Documents\\Visual Studio 2008\\Projects\\READOO\\READOO\\bin\\Debug\\READOO.exe.config line 6)" 
     Source="System.Configuration" 
     BareMessage="Section or group name 'READOO.Properties.Settings' is already defined. This can not be defined multiple times." 
     Filename="C:\\Users\\USER\\Documents\\Visual Studio 2008\\Projects\\READOO\\READOO\\bin\\Debug\\READOO.exe.config" 
     Line=6 
     StackTrace: 
      at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal) 
      at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors() 
      at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey) 
     InnerException: 

@ joan - >寒意。

+0

奇怪的是,這個錯誤發生在哪裏(例如運行時,vs設計器),並且你有任何步驟來重現。正如我剛剛嘗試刪除設置文件,但保持生成的類,它工作正常。 – 2009-08-21 21:54:13

+0

您可以調試錯誤並打破「配置系統初始化失敗」異常發生的位置嗎?如果是這樣,內部異常是否有任何進一步的信息是什麼導致問題? – adrianbanks 2009-08-21 22:20:19

+0

聽起來像某些東西可能無法反序列化,就像Adrian,檢查內部異常或任何其他可能包含完整錯誤消息的細節。 – 2009-08-21 22:47:50

回答

8

這將是您的線索:

節或組名 'READOO.Properties.Settings' 已定義。這不能被定義多次。 (C:\用戶\迪倫\文檔\ Visual Studio 2008的\項目\ READOO \ READOO \ BIN \調試\ READOO.exe.config 6號線)

你可能有內,在你的<configSections>定義2種<section name="READOO.Properties.Settings">元素配置文件。

重複條目最有可能在第6行的配置文件中。

0

這個問題是3歲,但問題永遠不會過時..萬一 有人絆倒在這個..

我有同樣的問題,當我複製一個配置節從 一個項目到另一個項目的app.config並未能複製 完整的命名空間..

<membership> 
    <providers> .. 

,而不是

<system.web> 
    <membership> 
     <providers> .. 

請確保您使用全套。

5

它也發生在我身上。解決方案是刪除Users \ yourUserName \ AppData \ Local \ YourAppName中的所有內容。

看起來當某些設置被保存爲用戶設置範圍,然後你轉動(在Settings.settings設計器中)它是應用程序的範圍設置得到搞砸的東西,VS不知道從哪裏取得設置值從。

現在,如果您只是添加一些設置作爲用戶範圍設置,然後將其設置爲應用程序範圍設置(不需要更改並以編程方式保存) - 一切正常。 但是,如果您使用Properties.Settings.Default.Save()保存設置,然後嘗試將其設置爲Application範圍,則會導致問題。

希望它有幫助。

+0

謝謝,我已經爲用戶範圍設置了一些意外設置。 – 2014-02-18 11:31:49

相關問題