"Unrecognized configuration section appsettings" exception thrown - Configuration.Appsettings(key)

H

hazz

I have spent more time than I care to admit trying to track down a very
subtle error.

Here is my app's xx.exe.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key="PasswordProvider" value="fudge" />
</appsettings>
</configuration>


Here is the code which reads the xx.exe.config file generated from the
app.config;
string val= "test" ;
string key = "test";
try
{
string filename =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

val=ConfigurationSettings.AppSettings[key];
}
catch(Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);

Here is the exception;
+ ex {@"Unrecognized configuration section appsettings
(C:\Webconfig.exe.config line 3)" } System.Exception

*************************
any ideas? I am certain the config file is well formed. This is a test
project with no other code to complicate this test.
Is there any possibility that anything in the WinXP environment I inherited
could alter any of Visual Studio's runtime?
Any setting in VS.NET options? Machine.config setttings? I can't remember
how to tell WinXP Pro how to add the security tab to the folder options for
me to check the folder security settings....but from the error message, that
doesn't appear to be the problem.

Thank you!
-greg
 
A

Arne Janning

hazz said:
I have spent more time than I care to admit trying to track down a very
subtle error.

Here is my app's xx.exe.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key="PasswordProvider" value="fudge" />
</appsettings>
</configuration>


Here is the code which reads the xx.exe.config file generated from the
app.config;
string val= "test" ;
string key = "test";
try
{
string filename =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

val=ConfigurationSettings.AppSettings[key];
}
catch(Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);

Here is the exception;
+ ex {@"Unrecognized configuration section appsettings
(C:\Webconfig.exe.config line 3)" } System.Exception

*************************
any ideas? I am certain the config file is well formed. This is a test
project with no other code to complicate this test.
Is there any possibility that anything in the WinXP environment I inherited
could alter any of Visual Studio's runtime?
Any setting in VS.NET options? Machine.config setttings? I can't remember
how to tell WinXP Pro how to add the security tab to the folder options for
me to check the folder security settings....but from the error message, that
doesn't appear to be the problem.


XML is case-sensitive.

It should be <appSettings>

http://msdn.microsoft.com/library/?url=/library/en-us/cpgenref/html/gngrfappsettingselement.asp

Cheers

Arne Janning
 
H

hazz

I guess I shouldn't have said "subtle" error. That is right there, front and
center.
Oh...my....GOSH....

Thank you Arne!! That's it.
-greg

Arne Janning said:
hazz said:
I have spent more time than I care to admit trying to track down a very
subtle error.

Here is my app's xx.exe.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key="PasswordProvider" value="fudge" />
</appsettings>
</configuration>


Here is the code which reads the xx.exe.config file generated from the
app.config;
string val= "test" ;
string key = "test";
try
{
string filename =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

val=ConfigurationSettings.AppSettings[key];
}
catch(Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);

Here is the exception;
+ ex {@"Unrecognized configuration section appsettings
(C:\Webconfig.exe.config line 3)" } System.Exception

*************************
any ideas? I am certain the config file is well formed. This is a test
project with no other code to complicate this test.
Is there any possibility that anything in the WinXP environment I inherited
could alter any of Visual Studio's runtime?
Any setting in VS.NET options? Machine.config setttings? I can't remember
how to tell WinXP Pro how to add the security tab to the folder options for
me to check the folder security settings....but from the error message, that
doesn't appear to be the problem.


XML is case-sensitive.

It should be <appSettings>

http://msdn.microsoft.com/library/?url=/library/en-us/cpgenref/html/gngrfappsettingselement.asp

Cheers

Arne Janning
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top