Where are config files for class libraries physically located?
- by BadNinja
My guess is that this question will fall under the category of "duh", but, nevertheless, I'm confused.
When using config files in, for example, a Windows Forms Application, the config file can be found in C:\Program files\CompanyName\ProductName\Application.exe.config. However, with the class library I'm developing I do not see a "ClassLibrary.dll.config" file in the install folder after installing it (in tandem with another project) from Visual Studio. Even though I do not see the file anywhere, retrieving data from it works correctly. Plus, running the following code from a method within the class library returns the path you would expect: C:\Program files\CompanyName\ProductName\ClassLibrary.dll.config.
If someone could shed some light on what I'm missing here, that would be really awesome.
public static string MyMethod()
{
Assembly assem = Assembly.GetExecutingAssembly();
Configuration config = ConfigurationManager.OpenExeConfiguration(assem.Location);
return "The assembly location was: " + assem.Location + Environment.NewLine +
"The config file path was: " + config.FilePath;
// Gives me "C:\Program files\CompanyName\ProductName\ClassLibrary.dll.config"
}