2009-08-21 62 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

相关问题