I have a C# class library A which has some configuration settings in its App.config I access them with
Method1()
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
}
But when I call Method 1() from my ASP Web project B, it cannot find the configurations settings in the Class library A
Any idea what is happening here?
The entire configuration management structure created by .Net runtime, is process-specific. not assembly specific. This means that each running executable gets an app.config. A Web project gets a web,config (actually a web project can have multiple web.configs), but assemblies cannot have their own app.configs, they can have code to read the configuration settings in the config file for whatever process they are being referenced in (which use the assembly as a reference in a winforms app, then it can see config settings in the MyWinformsApplication.exe.config; Use the assembly in an ASP.Net web app, then it can see confiog settings in the web applications’ web.config…