HTTP Error 500.19 - Internal Server Error: 0x8007007b Cannot read configuration file

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");

Comments (1) -

Brad Australia
6/30/2016 5:33:25 PM #

Wasted hours before I found this post.  Thanks.  Worked perfectly.

Comments are closed

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.