[Mono-bugs] [Bug 343459] New: Settings: NRE caused by app.config file

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Nov 21 13:13:49 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=343459

           Summary: Settings: NRE caused by app.config file
           Product: Mono: Class Libraries
           Version: 1.2.6
          Platform: 32bit
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: kobruleht2 at hot.ee
         QAContact: mono-bugs at ximian.com
          Found By: ---


To reproduce:

Run the application containing of 3 files below.

Observed:

System.NullReferenceException: Object reference not set to an instance of an
object
  at System.Configuration.SettingsPropertyValue.get_Name () [0x00000] 
  at System.Configuration.SettingsPropertyValueCollection.Add
(System.Configuration.SettingsPropertyValue property) [0x00000] 
  at System.Configuration.CustomizableFileSettingsProvider.LoadPropertyValue
(System.Configuration.SettingsPropertyCollection collection,
System.Configuration.SettingElement element, Boolean allowOverwrite) [0x00000] 
  at System.Configuration.CustomizableFileSettingsProvider.LoadProperies
(System.Configuration.ExeConfigurationFileMap exeMap,
System.Configuration.SettingsPropertyCollection collection,
ConfigurationUserLevel level, System.String sectionGroupName, Boolean
allowOverwrite) [0x00000] 
  at System.Configuration.CustomizableFileSettingsProvider.GetPropertyValues
(System.Configuration.SettingsContext context,
System.Configuration.SettingsPropertyCollection collection) [0x00000] 
  at System.Configuration.LocalFileSettingsProvider.GetPropertyValues
(System.Configuration.SettingsContext context,
System.Configuration.SettingsPropertyCollection properties) [0x00000] 
  at System.Configuration.ApplicationSettingsBase.CacheValuesByProvider
(System.Configuration.SettingsProvider provider) [0x00000] 
  at System.Configuration.ApplicationSettingsBase.GetPropertyValue
(System.String propertyName) [0x00000] 
  at System.Configuration.ApplicationSettingsBase.get_Item (System.String
propertyName) [0x00000] 
  at MyApp.Properties.Settings.get_Server () [0x00000] 
  at Test.Main () [0x00000] 


Environment:

1.2.6 Preview 2
NET 2 profile 
Windows XP 
VCSE 2008 B2


Files to reproduce:

*********** Program.cs:

using System;
using System.Windows.Forms;


public class Test {
        static void Main() {
                try {
                        string res=
global::MyApp.Properties.Settings.Default.Server;

                }
                catch (Exception ex) {
                        MessageBox.Show(ex.ToString());
                }
                }
}


********** Settings.Designer.cs

namespace MyApp.Properties {
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
   
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator",
"9.0.0.0")]
    internal sealed partial class Settings :
global::System.Configuration.ApplicationSettingsBase {

        private static Settings defaultInstance =
((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new
Settings())));

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

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


********** myapp.exe.config

<?xml version="1.0"?>
<configuration>
        <configSections>
                <sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
                        <section name="MyApp.Windows.Forms.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
                </sectionGroup>

                <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>

        </configSections>

        <userSettings>
                <MyApp.Windows.Forms.Properties.Settings>
                        <setting name="AutoLogin" serializeAs="String">
                                <value>False</value>
                        </setting>
                        <setting name="Server" serializeAs="String">
                                <value>localhost</value>
                        </setting>
                        <setting name="User" serializeAs="String">
                                <value>admin</value>
                        </setting>
                        <setting name="ConfigureOnRun" serializeAs="String">
                                <value>False</value>
                        </setting>
                </MyApp.Windows.Forms.Properties.Settings>
        </userSettings>

        <log4net debug="true">
                <appender name="rollingFile"
type="log4net.Appender.RollingFileAppender,log4net">

                        <param name="File" value="i:log.txt"/>
                        <param name="AppendToFile" value="false"/>
                        <param name="RollingStyle" value="Date"/>
                        <param name="DatePattern" value="yyyy.MM.dd"/>
                        <param name="StaticLogFileName" value="true"/>

                        <layout type="log4net.Layout.PatternLayout,log4net">
                                <param name="ConversionPattern" value="%d [%t]
%-5p %c - %m%n"/>
                        </layout>
                </appender>

                <root>
                        <priority value="ALL"/>
                        <appender-ref ref="rollingFile"/>
                </root>
        </log4net>

</configuration>


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list