I have a config file in my C# class library called MyLibrary.config, in vs 2008.
I created another project, say a simple console app, add reference by “Browsing” the MyLibrary.dll in the bin directory of the class library project, and when I compile, the MyLibrary.config is not including in the bin directory of the output in the console app.
How can I set it so I can include it when I reference the dll?
Cheers
You can’t. Your console application is expecting to find a config file with prefix the same as the name as the console application (
MyConsoleApplication.exe->MyConsoleApplication.exe.config.).In some situations you can share a config file by using the
fileattribute on theappSettingselement:Note that
pathis relative to the executing assembly.As a side note, DLLs do not even use the config file that you’ve defined in the project. Again, configuration information is read from the a config file with prefix the same as the executing assembly. Thus, even when
MyLibrary.dlltries to yank configuration information out of a config file, it will be reading the config file for the executing assembly, notMyLibrary.dll.config.For more on how config files work, see MSDN.