by Oliver
20. March 2013 15:24
While setting up a specification tests project for our new TeamReview tool, I was facing an HTTP 500.19 error when hosting our site in IIS Express. There are lots of questions on stackoverflow concerning this error, Microsoft has a whole page on it, but there is a whole bunch of suberrors that this error addresses.
Error 0x8007007b: Cannot read configuration file
Unfortunately, none of the above mentioned links contained or solved the specific error code I was seeing:
Error Code
0x8007007b
Config Error
Cannot read configuration file
Config File
\\?\C:\Projects\_teamaton\teamreview\TeamReview.Specs\bin\Debug\..\..\..\TeamReview.Web\web.config
After some reading, trying, fiddling, it appeared to me that maybe the path to the config file somehow messed up IIS Express. I admit that it was at least a bit unusual to use the parent directory dots. But it came from my test harness code where I wanted to use relative paths and used Path.Combine() to do that:
var webPath = Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "TeamReview.Web");
Pitfall: .. in path
Well, it turns out IIS Express didn't like it. Once I called it with a cleaned up path string, everything just worked:
"C:\Program Files (x86)\IIS Express\iisexpress.exe" /path:"C:\Projects\_teamaton\teamreview\TeamReview.Web" /port:12345 /systray:false
So, watch out for your physical path values when using IIS Express!
Use DirectoryInfo to navigate up your directory tree
To get the correct path without using absolute paths but also avoiding the .. I used the DirectoryInfo class:
var webPath = Path.Combine(
new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.FullName, "TeamReview.Web");