***** Update *****
This issue is directly related to a #R 4 EAP issue. I was using build 755 and this was an issue. As of build 762, this is no longer an issue.
********************
Today I encountered some odd behavior when trying to run some tests against my configuration object. I am hoping that someone out there has some insight for me.
My issue
I have a project that produces an assembly by the name of AccessKey.Domain.Tests.dll. Because I have a app.config file in the project, the config file is renamed to AccessKey.Domain.Tests.dll.config when the project is compiled.
The problem is that when I try to access the appSettings value in the config file I am only getting nulls. For what ever reason, the .net framework thinks my file should be named AccessKey.Domain.Tests.config (notice the .dll is missing from the name).
I have verified that the framework is in fact trying to pick up the wrong assembly by checking 2 things.
- System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
- ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None ).FilePath
Both of these have point to using the wrong config file name. I even tried to set the value in the System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile property, but that did not work.
My Resolution (but is lame)
In order to get this to work, I simply created a config file in my test project named AccessKey.Domain.Tests.config (again, notice the .dll is missing) and set the file to be copied to the output directory at compile time.
I don't like doing this as it feels dirty as well as it is not testing my system correctly.
Does anyone have a solution for my problem. In my 2+ years of testing, I have NEVER run into this issue....... HELP!
Till next time,