app.config adn web.config in same application.

C

craigkenisston

I have an asp.net application that uses the web.config to store some
settings. It uses a library that also has its own app.config file to
store their settings.
When I compile and run the asp.net, and I create an object from a class
that is in the library and that needs a configuration settings from the
library I see that the only available settings are the one in the
web.config file !! i.e. from the asp.net config, the library does not
see their own configuration settings.
Is there anyway to make this configuration to work ? or it is not
possible at all ? If so, is there any other way to do it ?
 
A

Arne Janning

Hi Craig!

I have an asp.net application that uses the web.config to store some
settings. It uses a library that also has its own app.config file to
store their settings.
When I compile and run the asp.net, and I create an object from a class
that is in the library and that needs a configuration settings from the
library I see that the only available settings are the one in the
web.config file !! i.e. from the asp.net config, the library does not
see their own configuration settings.
Is there anyway to make this configuration to work ? or it is not
possible at all ? If so, is there any other way to do it ?

app.config-files don't work with dlls. They are used to configure the
process that hosts the CLR through mscoree.dll. Actually mscoree.dll uses
Win32-API-GetModuleFileName to get the filename of the exe-file, that hosts
the CLR, appends ".config" to the filename and tries to get the
configuration-info from there. As in your case the CLR is hosted by w3wp.exe
oder aspnet_wp.exe your approach simply doesn't work.

There are ways to get around this problem:

Per-Assembly Configuration Files
http://www.bearcanyon.com/dotnet/#AssemblySettings

Cheers

Arne Janning
 

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