acsyssa
asked on
Unable to cast to type AppSettingsSection
I get "Unable to cast object of type 'System.Configuration.Defa ultSection ' to type 'System.Configuration.AppS ettingsSec tion'" when I´m trying to get values from a custom config file. Somebody help!!!
Code:
ConfigurationFileMap fileMap = new ConfigurationFileMap(CONFI G_PATH);
Configuration configuration = System.Configuration.Confi gurationMa nager.Open MappedMach ineConfigu ration(fil eMap);
value = configuration.AppSettings. Settings[k ey].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\CON TROLTEMPLA TES\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="EstadoProyectoFinaliz ado" value="Finalizado" />
<add key="AspectosPositivos" value="Aspectos Positivos" />
<add key="AscpectosAMejorar" value="Aspectos A Mejorar" />
<add key="ConnectionString" value="server=ttacsys\OFFI CESERVERS; database=S GTIdb ;uid=Franco;pwd=password;" />
<!--ID item Presupuesto de ProyectoLibreriaTemplates -->
<add key="IDPresupuestoLibTempl ates" value="15" />
</appSettings>
<connectionStrings/>
</configuration>
Code:
ConfigurationFileMap fileMap = new ConfigurationFileMap(CONFI
Configuration configuration = System.Configuration.Confi
value = configuration.AppSettings.
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\CON
<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,
<add key="EstadoProyectoFinaliz
<add key="AspectosPositivos" value="Aspectos Positivos" />
<add key="AscpectosAMejorar" value="Aspectos A Mejorar" />
<add key="ConnectionString" value="server=ttacsys\OFFI
<!--ID item Presupuesto de ProyectoLibreriaTemplates -->
<add key="IDPresupuestoLibTempl
</appSettings>
<connectionStrings/>
</configuration>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.