Raja
Raja

Reputation: 3618

DLL appsettings returns null (looking at web.config instead of DLLs app.config)

We have a DLL and it has its own app settings. Now if I use the dll in the ASP .Net website, ConfigurationManager.AppSettings[key] is looking at website's web.config instead of DLL's App.config.

Is it possible to get the config settings in the DLL's app.config rather than website's web.config?

Any help is much appreciated.

Thanks,

Raja

Upvotes: 2

Views: 1031

Answers (2)

Oded
Oded

Reputation: 499272

A DLL cannot have its own configuration.

A library executes in the context of an application (web or otherwise) - the configuration is that of this application.

Upvotes: 3

Savas
Savas

Reputation: 77

I'm using the code below to get my dll's config. Hope it helps.

_config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
_rootPath = _config.AppSettings.Settings["RootPath"].Value;

Upvotes: 1

Related Questions