Well, this question is a bit different from others with the slightly same title.
I add a config file to my DLL which will be used from a website and a console application. I'm testing the DLL from my web application.
When I build the DLL I can see my MyApp.dll.config
in the bin\debug
folder.
Nevertheless, when I try to read the settings from the DLL this way:
var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
The file is not found.
I know it is something to do with the location where the application is being executed as Assembly.GetExecutingAssembly().Location
return a path in Framework\v4.0.30319\Temporary ASP.NET Files\root\...
while AppDomain.CurrentDomain.BaseDirectory
return another completely different path.
So, what I'm doing wrong? There is some configuration missing to get the config file to be copied in the real location where the application is being ran?
Thank you in advance from your help!