Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to retrieve an application setting
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01482778
Message ID:
01482789
Vues:
55
The syntax that you're using applies to the pre-defined 'appSettings' section - which is not what you are dealing with here. I don't know if there's a more elegant way of accessing a ClientSettingsSection but something like this will work:
ClientSettingsSection y = (ClientSettingsSection) ConfigurationManager.GetSection("applicationSettings/MYEXE.Properties.Settings");
string s = y.Settings.Get("CSVFile").Value.ValueXml.InnerText;
UPDATE: If the app.config was created from Settings.Settings then won't this work:
string s = Properties.Settings.Default.CSVFile;
>I am trying to retrieve an application setting but an empty string is being returned on a Windows FormApplication
>
> string importFile = System.Configuration.ConfigurationManager.AppSettings["CSVFile"];
> MessageBox.Show("Import File = " + importFile);
>
>My MyApp.Exe_Config is:
>
>
><?xml version="1.0" encoding="utf-8" ?>
><configuration>
>    <configSections>
>        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
>            <section name="MYEXE.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
>        </sectionGroup>
>    </configSections>
>    <applicationSettings>
>        <MYEXE.Properties.Settings>
>            <setting name="CSVFile" serializeAs="String">
>                <value>This is a CSV File Setting</value>
>            </setting>
>        </MYEXE.Properties.Settings>
>    </applicationSettings>
></configuration>
>
>
>Any ideas of what could be wrong.
>TIA, Gerard
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform