Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Serialize and Deserialize
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00691120
Message ID:
00691460
Vues:
14
>
>OK, yeah, it looks like I need the ConfigurationSettings (GetConfig) class since this isn't quite application-level stuff. But, it would fit nicely in the user-defined portion of the configuration file. Thanks.

I (mistakenly) thought this would be easier than it has turned out to be. Since I'm trying to create a stand-alone class, I had to create a test app so I could try things out. At first, it choked on ANY entry I made to app.config, so I just commented out the form code that called System.Configuration.AppSettingsReader. Then I was able to add a new section to app.config. Now it's throwing an error when I attempt to read this section. I've played around with it and done some searching but I haven't found anything that has helped. My app.config looks like:
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
  <appSettings>
    <!--   User application and configured property settings go here.-->
    <!--   Example: <add key="settingName" value="settingValue"/> -->
    <add key="button1.Enabled" value="True" />
  </appSettings>
  <TestConfig>
    <add key="sampleKey" value="true" />  
  </TestConfig>   
</configuration>
and my code looks like:
try
{
   NameValueCollection config = (NameValueCollection) ConfigurationSettings.GetConfig("TestConfig");	

          
}
catch (ConfigurationException e)
{
   // Error
				
   System.Diagnostics.Debug.Assert(false, "Exception Caught", e.Message );
}
It fails in the GetConfig line saying "Unrecognized configuration section TestConfig". How should this stuff be formatted for it to work correctly?

Thanks,
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform