[Mono-dev] Save user's settings

Mixim mixim33 at yandex.ru
Sun Aug 19 09:15:36 UTC 2012


Hello everyone. User must get some information for setting my program. I want
to save this settings but how can I do it?
I attache "app.config" file to my project and pust there some default
settings which I'm by next way:
String
userSetting1=System.Configuration.ConfigurationManager.AppSetings["userSetting1"];
but how can I save new settings? Next code does not work (program is
closed):
		string userSetting1=ConfigurationManager.AppSettings["userSetting1"];
		
		userSetting1+=insertToUserSetting_entry.Text;
		
		ConfigurationManager.AppSettings["userSetting1"]=userSetting1;//program is
closed with the following log

Marshaling clicked signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to
handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Configuration.ConfigurationErrorsException: Error Initializing the
configuration system. --->
System.Configuration.ConfigurationErrorsException: Unrecognized
configuration section <configSections>
(/home/mixim/TestParametersGroup/TestParametersGroup/bin/Debug/TestParametersGroup.exe.config
line 13)
  at System.Configuration.ConfigInfo.ThrowException (System.String text,
System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlReader
reader, System.Configuration.Configuration config, Boolean overrideAllowed,
Boolean root) [0x00000] in <filename unknown>:0 
  at System.Configuration.SectionGroupInfo.ReadRootData
(System.Xml.XmlReader reader, System.Configuration.Configuration config,
Boolean overrideAllowed) [0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader
reader, System.String fileName) [0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration.Load () [0x00000] in <filename
unknown>:0 
  at System.Configuration.Configuration.Init (IConfigSystem system,
System.String configPath, System.Configuration.Configuration parent)
[0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration..ctor
(System.Configuration.InternalConfigurationSystem system, System.String
locationSubPath) [0x00000] in <filename unknown>:0 
  at System.Configuration.InternalConfigurationFactory.Create (System.Type
typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in
<filename unknown>:0 
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal
(ConfigurationUserLevel userLevel, System.Reflection.Assembly
calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0 
  at System.Configuration.ClientConfigurationSystem.get_Configuration ()
[0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration ()
[0x00000] in <filename unknown>:0 
  at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
(System.String configKey) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String
sectionName) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000]
in <filename unknown>:0 
  at MainWindow.OnButton1Clicked (System.Object sender, System.EventArgs e)
[0x00000] in
/home/mixim/TestParametersGroup/TestParametersGroup/MainWindow.cs:87 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[]
parameters) [0x00000] in <filename unknown>:0 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in
<filename unknown>:0 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args)
[0x00000] in <filename unknown>:0 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in
<filename unknown>:0 
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs
args) [0x00000] in <filename unknown>:0 
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in
<filename unknown>:0 
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr
return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr
invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e,
Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr
return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr
invocation_hint, IntPtr marshal_data)
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at TestParametersGroup.MainClass.Main(System.String[] args) in
/home/mixim/TestParametersGroup/TestParametersGroup/Main.cs:line 13
The application was terminated by a signal: SIGHUP


My "app.config" file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>

<appSettings>

    <add key="userSetting1" value="userSetting1" />
    <add key="userSetting2" value="userSetting2" />

		
 </appSettings>
	
	
</configuration>




--
View this message in context: http://mono.1490590.n4.nabble.com/Save-user-s-settings-tp4656314.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list