Da quando ho cancellato il file settings.settings originale ho avuto infiniti problemi nel far funzionare le impostazioni. Ricevo l'errore "Impossibile inizializzare il sistema di configurazione" sui metodi get o set. Qualche idea? Grazie."Impossibile inizializzare il sistema di configurazione" quando si accede a 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;
}
}
problema si trova nel Settings.Designer.cs
Adrian Banks, temo non so come ulteriormente il debug? Si rompe già sull'errore. L'intestazione della casella data è "ConfigurationErrorsException" se questo aiuta in alcun modo.
Mi scuso, non mi sono reso conto che potresti vedere ulteriori dettagli in 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 -> freddo.
Dispari, dove si verifica questo errore (ad esempio runtime, vs designer) e hai qualche procedura per la riproduzione.Come ho appena provato a cancellare il file delle impostazioni ma mantenendo la classe che è stata generata e funziona bene. –
È possibile eseguire il debug dell'errore e interrompere l'errore in cui si è verificata l'eccezione "Impossibile inizializzare il sistema di configurazione"? In tal caso, l'eccezione interna ha ulteriori informazioni su cosa sta causando il problema? – adrianbanks
Sembra che qualcosa potrebbe non riuscire a deserializzare, come Adrian, controllare le eccezioni interne o qualsiasi altro dettaglio che potrebbe contenere un messaggio di errore completo. –