Application Config File 
Author Message
 Application Config File

Not sure if this jives with what you've read, but you need to name the file
appname.exe.config yourself, and put it into the output directory.  Then it
will pick this up at run-time and you'll be able to read from it.

Jeff Woodie


Quote:
> Can someone tell me how to get C# to read from an application
configuration
> file? I created an XML file named appname.config and placed it in the main
> directory. In this file I added statements to control BooleanSwitches in
> console application, appname.cs. From what I have read so far, the C#
> compiler should look for the appname.config file when doing a build and
copy
> it to the output directory and name it appname.exe.config. However the
> compiler completely ignores this file and the config file does not get
read
> during execution. I've tried placing the config file in the output
directory
> but this does not work either.

> I have gotten this to work in VB using App.config but cannot make C#
> recognize the existence of the configuration file.

> TIA



Mon, 18 Apr 2005 02:08:24 GMT  
 Application Config File
I could swear I tried that at least 4 times but it did not work until I read
your reply!

Thanks for the help!


Quote:
> Not sure if this jives with what you've read, but you need to name the
file
> appname.exe.config yourself, and put it into the output directory.  Then
it
> will pick this up at run-time and you'll be able to read from it.

> Jeff Woodie



> > Can someone tell me how to get C# to read from an application
> configuration
> > file? I created an XML file named appname.config and placed it in the
main
> > directory. In this file I added statements to control BooleanSwitches in
> > console application, appname.cs. From what I have read so far, the C#
> > compiler should look for the appname.config file when doing a build and
> copy
> > it to the output directory and name it appname.exe.config. However the
> > compiler completely ignores this file and the config file does not get
> read
> > during execution. I've tried placing the config file in the output
> directory
> > but this does not work either.

> > I have gotten this to work in VB using App.config but cannot make C#
> > recognize the existence of the configuration file.

> > TIA



Mon, 18 Apr 2005 03:25:24 GMT  
 Application Config File
Do the same as VB - name the file App.config. VS.NET will only copy the file
to the output directory is the file is named App.config. Anything else will
get ignored.

Joe


Quote:
> Can someone tell me how to get C# to read from an application
configuration
> file? I created an XML file named appname.config and placed it in the main
> directory. In this file I added statements to control BooleanSwitches in
> console application, appname.cs. From what I have read so far, the C#
> compiler should look for the appname.config file when doing a build and
copy
> it to the output directory and name it appname.exe.config. However the
> compiler completely ignores this file and the config file does not get
read
> during execution. I've tried placing the config file in the output
directory
> but this does not work either.

> I have gotten this to work in VB using App.config but cannot make C#
> recognize the existence of the configuration file.

> TIA



Mon, 18 Apr 2005 03:29:08 GMT  
 Application Config File
It works just like VB now. I've read all the documentation I could get my
hands on and naming the file App.config in C# was not mentioned anywhere
(including MSDN).

Thanks for the help!


Quote:
> Do the same as VB - name the file App.config. VS.NET will only copy the
file
> to the output directory is the file is named App.config. Anything else
will
> get ignored.

> Joe



> > Can someone tell me how to get C# to read from an application
> configuration
> > file? I created an XML file named appname.config and placed it in the
main
> > directory. In this file I added statements to control BooleanSwitches in
> > console application, appname.cs. From what I have read so far, the C#
> > compiler should look for the appname.config file when doing a build and
> copy
> > it to the output directory and name it appname.exe.config. However the
> > compiler completely ignores this file and the config file does not get
> read
> > during execution. I've tried placing the config file in the output
> directory
> > but this does not work either.

> > I have gotten this to work in VB using App.config but cannot make C#
> > recognize the existence of the configuration file.

> > TIA



Mon, 18 Apr 2005 04:35:17 GMT  
 Application Config File
Can someone tell me how to get C# to read from an application configuration
file? I created an XML file named appname.config and placed it in the main
directory. In this file I added statements to control BooleanSwitches in
console application, appname.cs. From what I have read so far, the C#
compiler should look for the appname.config file when doing a build and copy
it to the output directory and name it appname.exe.config. However the
compiler completely ignores this file and the config file does not get read
during execution. I've tried placing the config file in the output directory
but this does not work either.

I have gotten this to work in VB using App.config but cannot make C#
recognize the existence of the configuration file.

TIA



Mon, 18 Apr 2005 01:55:23 GMT  
 Application Config File
It actually is mentioned somewhere, but it was very difficult to find. In
fact, I couldn't find it until after I knew the answer and knew _exactly_
what to look for.

I hope they do something to make it more obvious in VS.NET because this
seems to be a very common question...

To go along with this thread, has anyone found a way to do the same thing
with a library project? For example, I have a library project that will
output the assembly MyAssembly.dll. I want a config file copied to the
output directory as MyAssembly.dll.config. However, the little trick of
naming the config file App.config only seems to work on exe output projects,
and is completely ignored on non-exe output projects.

Joe


Quote:
> It works just like VB now. I've read all the documentation I could get my
> hands on and naming the file App.config in C# was not mentioned anywhere
> (including MSDN).

> Thanks for the help!



> > Do the same as VB - name the file App.config. VS.NET will only copy the
> file
> > to the output directory is the file is named App.config. Anything else
> will
> > get ignored.

> > Joe



> > > Can someone tell me how to get C# to read from an application
> > configuration
> > > file? I created an XML file named appname.config and placed it in the
> main
> > > directory. In this file I added statements to control BooleanSwitches
in
> > > console application, appname.cs. From what I have read so far, the C#
> > > compiler should look for the appname.config file when doing a build
and
> > copy
> > > it to the output directory and name it appname.exe.config. However the
> > > compiler completely ignores this file and the config file does not get
> > read
> > > during execution. I've tried placing the config file in the output
> > directory
> > > but this does not work either.

> > > I have gotten this to work in VB using App.config but cannot make C#
> > > recognize the existence of the configuration file.

> > > TIA



Mon, 18 Apr 2005 05:49:12 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Application config files - pros and cons

2. config file for a windows form application

3. Updating the security.config file in the CONFIG directory

4. Managing .config files for C# applications.

5. How to config RAS phoneook in my Control Panel Application

6. Application config info - dbconn strings, preferences, etc

7. admin.config vs machine.config

8. Can you access .config files in DLL assemblies?

9. Example of Creating and Accessing .Config file

10. Improvements to .config files

11. Best way to have config file for Assembly?

12. physical path to .exe and .config file...?

 

 
Powered by phpBB® Forum Software