Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to ensure a class library uses it's own app settings?

I have a class library at the moment and it's going to need its own appsettings and it's likely going to need to change them and stuff.

The only problem is that the class is going to be called by a web application which has an appsettings file that also has identical keys to the class library app settings.

I would like to ensure that the class library uses it's own appsettings file and also that it doesn't make changes to the web application's appsettings.

Is this possible? It seems like any assembly can change the appsettings via ConfigurationManager.

EDIT - To give context, the class library accesses a data tier assembly (which I can't change) which uses a value in the appSettings to get the connection string. Only problem is that key is the same as the web app's connection string (which may or may not have a different value).

I don't want the class library to change the appSetting value for that key, and then have the web app start accessing a different database.

like image 520
Diskdrive Avatar asked May 19 '11 01:05

Diskdrive


1 Answers

A separate app domain can use a different config file, I believe. I'm not sure how else you could do it.

like image 121
Matthew Lund Avatar answered Sep 28 '22 02:09

Matthew Lund