Stupid App.Config Question

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have a client app as one project and a data access class
library as another project. I have put app.config files
everywhere and named them everything. If I name it
MyApp.exe.config and put it in the client's bin directory,
the client can get to it but I can't make the data access
assembly access it.

Any Ideas?

Thanks
 
By default, if you use the configuration namespace within a DLL it will look
for the App.config of the application using the DLL.
 
I have a client app as one project and a data access class
library as another project. I have put app.config files
everywhere and named them everything. If I name it
MyApp.exe.config and put it in the client's bin directory,
the client can get to it but I can't make the data access
assembly access it.

Well, basically, assemblies (DLL's) don't support reading their own
app config files out of the box - they'll always try to revert to the
config file of the app calling them.

You'd have to work around this by using some kind of a third-party
config reader, which allows you to specify exactly which config file
you want to inspect / evaluate.

Check out this component as a sample - there are a few more out there:

http://www.codeproject.com/csharp/Custom_Config_File_Reader.asp

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top