VS 2010: An error occurred loading a configuration file: Failed to map the path ‘/’.


I was using the System.Web.Configuration.WebConfiguration class to open the configuration for the site from one of my logic dll’s and I got the wonderful error An error occurred loading a configuration file: Failed to map the path ‘/’.

I freaked out for a second, until I put more thought into it. This is running fine in production! What is the difference with my machine and the server?

Oh! My Visual Studio is running under UAC with limited privileges since I am in Windows 7. DUH!

So, I restarted Visual Studio 2010 under “Run as Administrator” and problem solved. So if you are on Vista or Windows 7, that’s the issue.

NOTE: If you develop with administrative rights, be careful you don’t make development mistakes that assume everyone will run your program as an admin. i.e. writing to program files directory, root directory, etc.

Happy Coding!

, , , , , ,

  1. #1 by Manjunath on May 18, 2010 - 3:58 am

    Hi ,

    I have the same Problem. It is solved once you open the VS2008 with admin rights.

    Does it make any problem if i deploy the site as it is on server ?

  2. #2 by Brian Seekford on May 19, 2010 - 2:27 pm

    It only matters when running using Cassini, which is the development web hosting engine. When you publish to a server, the IIS instance has the rights to execute properly.

  3. #3 by gallit on September 14, 2010 - 5:20 am

    hie,
    i had the same problem and found a solution without starting vs2010 under admin.
    instead of using the openwebconfiguration method, i use directly the properties avalaible for reading.

    WebConfigurationManager.AppSettings["MyAppS"]
    WebConfigurationManager.ConnectionStrings["myCS"]

  4. #4 by Les on May 27, 2011 - 2:40 pm

    Thanks! I was pulling my hair out and your post make everything right!

  5. #5 by kinne on August 30, 2011 - 3:06 am

    Thanks!

  6. #6 by DevPartner on October 21, 2011 - 6:35 am

    Many Thanks!

  7. #7 by Tapan on December 8, 2011 - 12:49 am

    Hello Experts,

    I also faced the same error while i am generating workflow in Sybase. Can you please tell me in which i have to change , and above comments, which solutions is right ?

(will not be published)