Link to home
Start Free TrialLog in
Avatar of acsyssa
acsyssa

asked on

Unable to cast to type AppSettingsSection

I get "Unable to cast object of type 'System.Configuration.DefaultSection' to type 'System.Configuration.AppSettingsSection'" when I´m trying to get values from a custom config file. Somebody help!!!

Code:
                    ConfigurationFileMap fileMap = new ConfigurationFileMap(CONFIG_PATH);
                    Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap);
                    value = configuration.AppSettings.Settings[key].Value;

Config File:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="FeedCacheTime" value="300" />
    <add key="FeedPageUrl" value="/_layouts/feed.aspx?" />
    <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" />
    <add key="ReportPath" value="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\SGPT\" />
    <add key="ProjectSite" value="Enabled" />
    <add key="ProjectTemplate" value="proyectoSGPT70" />
    <add key="TestMode" value="Off" />
    <add key="ADRefreshMinutes" value="20" />
    <add key="SGPTWebURL" value="http://ttacsys/" />
    <add key="WebAdmin" value="User=administrator, Password=password" />
    <add key="EstadoProyectoFinalizado" value="Finalizado" />
    <add key="AspectosPositivos" value="Aspectos Positivos" />
    <add key="AscpectosAMejorar" value="Aspectos A Mejorar" />
    <add key="ConnectionString" value="server=ttacsys\OFFICESERVERS;database=SGTIdb ;uid=Franco;pwd=password;" />
    <!--ID item Presupuesto de ProyectoLibreriaTemplates -->
    <add key="IDPresupuestoLibTemplates" value="15" />
  </appSettings>
  <connectionStrings/>
</configuration>
ASKER CERTIFIED SOLUTION
Avatar of lenordiste
lenordiste
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial