I have a .net app that I just opened on in visual studio 2010 and converted to 4.0 when it asked me on start-up. I go to try to build the site, and I get this error:
<
We had the same problem, IISRESET didn't do it.
It turned out that the Virtual Directory we trying to map has a double backslash (d:\folder\\subfolder\
) in the naming (IIS virtual directory was created with powershell script). Removing the extra backslash made HostingEnvironment.MapPath stop throwing exceptions.
Just in the case this could help somebody :-)