Eclipsed4utoo's Blog
Not Your Ordinary Programmer

Posts Tagged ‘wpf’

WPF – Using an Application Configuration File

Fri ,05/02/2010

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 like I would in a Windows Form..
AppConfig

My app config file looked something like this…

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
     <add key="myKey" value="SomeValue" />
  </appSettings>
</configuration>

I was using the standard code that works fine in Windows Forms(needed to add a reference to the System.Configuration):

using System.Configuration

private void Window_Loaded(object sender, RoutedEventArgs e)
{
     var myKey = ConfigurationManager.AppSettings["myKey"];
}

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 “MVP”s picked up on it.  It was because of the name of the app config file.  By default, VS2008 added the file as “App1.config”.  For some reason, the ConfigurationManager class looks for a file named exactly “App.config”.

So simply changing the name of the config file to “App.config” fixed the issue and the code started working.

TwitEclipse – My Twitter Desktop Client

Mon ,12/10/2009

I have released a BETA version of my Twitter Desktop Client called TwitEclipse.  I have been writing a Twitter API library in .Net for a while now, and figured I might as well write a desktop client also.

The client uses .Net 3.5 SP1 and WPF.  It was a great learning experience to learn WPF since I had almost no previous experience with it.

If you want to download it and test it out, you can download it from here.  Remember that it is a BETA.  You could run into issues.  If you do, be sure to let me know so I can fix them.  I will also be adding additional features to the app once I get a chance.

I will be releasing my Twitter API library soon also.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes