Try putting this in your web.config:
<appSettings file="externalSettings.config"/>
externalSettings.config is the other config file you want to use.
For a non web assembly, it looks for AssemblyName.dll where AssemblyName corresponds to your assembly name. Ex: if your assembly name is Com.MyProject.Library1.dll
, then the config file it's looking for is Com.MyProject.Library1.dll.config
.
UPDATE:
I did some more research on this, and as noted here, "The ConfigurationManager will read from the configuration file that was loaded by the AppDomain when it loaded the application". So in the case of your web application, it's going to read from the web.config file if you are accessing ConfigurationManager
from within your aspx code.
I think the most suitable workaround to do what you want is the workaround I've already provided, namely, to use the appSettings
configuration parameter which will allow you to have a shared configuration file for your aspx app and your class library.
As an example, in your shared configuration file, you'd want something like this:
<appSettings>
<add key="Key1" value="test"/>
</appSettings>
Let's say this file was c:\temp\shared.config
. Then in your web.config, you could refer to it like this:
<appSettings file="C:\\temp\\shared.config"></appSettings>
You would put this same line in your class library's app.config.
And now you'll be able to use:
ConfigurationManager.AppSettings["Key1"]
from either your aspx app or your class library and you'll get the value.
So if you really need "common" configuration parameters shared across aspx and class libraries, this is the way to do it.