<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eclipsed4utoo&#039;s Blog&#187; ConfigurationManager</title>
	<atom:link href="http://eclipsed4utoo.com/blog/tag/configurationmanager/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsed4utoo.com/blog</link>
	<description>Not Your Ordinary Programmer</description>
	<lastBuildDate>Fri, 23 Jul 2010 18:10:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WPF &#8211; Using an Application Configuration File</title>
		<link>http://eclipsed4utoo.com/blog/wpf-application-configuration-file/</link>
		<comments>http://eclipsed4utoo.com/blog/wpf-application-configuration-file/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 19:16:01 +0000</pubDate>
		<dc:creator>Ryan Alford</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[app.config]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ConfigurationManager]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://eclipsed4utoo.com/blog/?p=292</guid>
		<description><![CDATA[This is going to be a real short post about an issue that I ran into recently with WPF.
I was wanting to use an app config file with my WPF application.  I was running into an issue with the ConfigurationManager calls not getting the information from the app config file.
I added the app config just [...]]]></description>
			<content:encoded><![CDATA[<p>This is going to be a real short post about an issue that I ran into recently with WPF.</p>
<p>I was wanting to use an app config file with my WPF application.  I was running into an issue with the ConfigurationManager calls not getting the information from the app config file.</p>
<p>I added the app config just like I would in a Windows Form..<br />
<img class="alignnone size-full wp-image-293" title="AppConfig" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/02/AppConfig.png" alt="AppConfig" width="679" height="418" /></p>
<p>My app config file looked something like this&#8230;</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;configuration&gt;
  &lt;appSettings&gt;
     &lt;add key=&quot;myKey&quot; value=&quot;SomeValue&quot; /&gt;
  &lt;/appSettings&gt;
&lt;/configuration&gt;
</pre>
<p>I was using the standard code that works fine in Windows Forms(needed to add a reference to the System.Configuration):</p>
<pre class="brush: csharp;">
using System.Configuration

private void Window_Loaded(object sender, RoutedEventArgs e)
{
     var myKey = ConfigurationManager.AppSettings[&quot;myKey&quot;];
}
</pre>
<p>However, the app settings were not being found.  After scratching my head for a while and searching numerous places online, I found a small response on a forum.  None of the &#8220;MVP&#8221;s picked up on it.  It was because of the name of the app config file.  By default, VS2008 added the file as &#8220;App1.config&#8221;.  For some reason, the ConfigurationManager class looks for a file named exactly &#8220;App.config&#8221;.</p>
<p>So simply changing the name of the config file to &#8220;App.config&#8221; fixed the issue and the code started working.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsed4utoo.com/blog/wpf-application-configuration-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
