Michael Michael - 4 months ago 55
C# Question

How does ConfigurationManager.ConnectionStrings work?

So I have a Solution with 1 Class Library and 1 MVC project. The MVC project references the Class Library.
I created a ConnectionString class in the Class library that looks like this:

public static string MyAppConnectionString { get; set; } =

Everything is working fine. But what I don't understand is how ConfigurationManager.ConnectionStrings knows about the ConnectionStrings of BOTH the app.config file of the Class library AND the Web.Config file of the MVC project?


ConfigurationManager works against the app.config file of the currently running executable, or in the case of web applications, against the web.config file. It does not use the app.config found in your library project.