Where is the app.exe.config supposed to go?

  • Thread starter Richard Lewis Haggard
  • Start date
R

Richard Lewis Haggard

I have a test application that is calling an assembly that reads some
strings out of a config file. Normally, this assembly supports a web
application and the information can be read just fine. Then I created a C#
test application and ran the function. The function fails because the
configuration read is failing to find a key. I created an application config
and copied the keys over to the app config file but the app is still failing
to find the keys. It isn't clear what the problem is. Maybe the app is not
finding the config file or perhaps there's something else going on. Where
should the app exe config go?

Here's the situation:

Dev Studio 2003.
D:\Projects\A\bin contains a dozen different assemblies that the test
program needs.
Test program is output to D:\Projects\A\bin.
Name of test program is TestAccount.exe.
Name of app config is TestAccount.exe.config.

When I put the config in D:\Projects\A\bin, the application throws an error
because it can't read a key from the config file.
Oddly, after the program has run, the config file is no longer present in
D:\Projects\A\bin. Could it be that the config file is getting deleted as
soon as the program tries to read the key?
Thinking that maybe the executable's directory wasn't the right place, I
tried other places (Windows, Windows\System32 and a bunch of other places)
but that didn't seem to work.
 
R

Richard Lewis Haggard

The problem is that the TestAccount.exe.config file is being deleted
sometime soon after TestAccount.exe starts. Does this ring a bell with
anyone?
 
R

Richard Lewis Haggard

Never mind. Figured it out.

Here's what I did wrong - I renamed the app.config to
TestAccount.exe.config. What I didn't know was that Dev Studio will
automatically output the contents of app.config to TestAccount.exe.config in
the project's output directory. What I'm guessing is, Dev Studio recognized
that an app config existed but, because I'd renamed the file in the
solution, Dev Studio was deleting the TestAccount.exe.config in the output
directory but was failing when it tried to rename app.config to
TestAccount.exe.config. Anyway, once I'd renamed the config in the solution
back to the default name, things worked better.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Richard Lewis Haggard said:
The problem is that the TestAccount.exe.config file is being deleted
sometime soon after TestAccount.exe starts. Does this ring a bell with
anyone?
 
S

Stoitcho Goutsev \(100\)

Application config file must reside in the application folder (where the
executable is)
 

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