[Mono-list] Properties.Settings.Default and mono

Chris Toshok toshok at ximian.com
Thu May 4 14:39:07 EDT 2006


Please file a bug on this (and include a test case that shows the
behavior.)

Chris

On Thu, 2006-05-04 at 17:22 +0200, Matthias Leonhardt wrote:
> Hi monodevelopers,
> 
> I created a little VS2005 Project (.NET 2.0) and I'm using the new
> app.config to preset some Settings.
> 
> In the program code I access it the following way:
> Console.WriteLine(Properties.Settings.Default.HostName);
> 
> HostName is a String Setting which is stored correctly in app.config:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>     <configSections>
>         <sectionGroup name="userSettings"
> type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089" >
>             <section name="HostInfoServer.Properties.Settings"
> type="System.Configuration.ClientSettingsSection, System,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
>         </sectionGroup>
>     </configSections>
>     <userSettings>
>         <HostInfoServer.Properties.Settings>
>             <setting name="HostName" serializeAs="String">
>                 <value>localhost</value>
>             </setting>
>         </HostInfoServer.Properties.Settings>
>     </userSettings>
> </configuration>
> 
> If I start the application in windows everything works - if I start it with
> mono appname.exe
> in linux I get the following error:
> Unhandled Exception: System.TypeInitializationException: An exception
> was thrown by the type initializer for HostInfoServer.Program --->
> System.TypeInitializationException: An exception was thrown by the type
> initializer for HostInfoServer.Properties.Settings --->
> System.ArgumentNullException: null key
> Parameter name: key
> in <0x00182> System.Collections.Hashtable:get_Item (System.Object key)
> in <0x00012> System.Configuration.SettingsProviderCollection:get_Item
> (System.String name)
> in <0x004f6> System.Configuration.ApplicationSettingsBase:get_Properties ()
> in <0x00023> System.Configuration.ApplicationSettingsBase:.ctor ()
> in <0x0000a> HostInfoServer.Properties.Settings:.ctor ()
> in <0x00016> HostInfoServer.Properties.Settings:.cctor ()--- End of
> inner exception stack trace ---
> 
> in <0x00000> <unknown method>
> in <0x00009> HostInfoServer.Program:.cctor ()--- End of inner exception
> stack trace ---
> 
> This error seems to occure before the first line of my own code is executed.
> What's wrong and what can I do to fix this?
> 
> thanks for your help!
> 
> kind regards,
> Matthias Leonhardt, Jena
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list


More information about the Mono-list mailing list