I'd like to use some of the techniques discussed here for reading a
config file in .NET 2.0:
http://msdn.microsoft.com/msdnmag/is...s/default.aspx
Here's my app.config content:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="DebugCleanFile" type="System.Boolean,
ConfigurationProperty, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" allowDefinition="Everywhere"
allowExeDefinition="MachineToApplication"
restartOnExternalChanges="true" value="true"/>
</configSections>
<system.diagnostics>
</system.diagnostics>
</configuration>
Here's the code snippet:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestConsole
{
class RunProg
{
public static void Main( string[ ] args )
{
AppConfigFileEngine appconfig = new AppConfigFileEngine();
object debugClean = appconfig.DebugCleanFile.DefaultValue;
}
}
class AppConfigFileEngine :
System.Configuration.ConfigurationSection
{
public System.Configuration.ConfigurationProperty
DebugCleanFile = new
System.Configuration.ConfigurationProperty("DebugC leanFile",
typeof(bool));
}
}
The default value on debugClean is always false. I also get this
warning from the app.config file:
The 'value' attribute is not declared.
I simply want to read a different properties, along with their set
value, out of the config file using something similar to the above
structure. What am I doing wrong?
I'd also like to declare debugClean as a bool instead of object. How
can that be done?
Thanks,
Brett