Windows Forms Application Config File Not Read

G

Guest

I have my first windows forms application in which I have added a
configuration file. I have two keys and either the file is not being read or
it is not happy with the way the file is structured. I welcome any ideas on
why this occurring.

The file is in the same directory as the application.
It is named <appname>.exe.xml

This is the contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ComName" value="MyTest.dll" />
<add key="ComponentGUID" value="{CE6E1632-CAE3-4CD1-A443-FBE9A003977B}" />
</appSettings>
</configuration>
 
C

Claes Bergefall

Content looks fine but the naming is incorrect.
Rename it to <appname>.exe.config

/claes
 
G

Guest

Still same thing. It appears that the application knows nothing about a
configuration file. Do I need to declare it somewhere in the project? I
thought that adding a config file to the project would take care of anything
that was necessary. How can I check if it knows what the configuration file
is through reflection?

I initially added a new configuration file to the project and called it
app.Config. I then edited the file as shown in the original post. I saved
the file and copied it into the bin directory of the application. It is
saved in the bin folder as <appname>.exe.config When I hit the debug point
where it should be reading it, this code shows
ConfigurationSettings.AppSettings.haskeys = "False"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top