The web application at [URL] could not be found

SPSite site = new SPSite(yourWebUrl) fails in console or win application 

If trying to extecute SPSite site = new SPSite(yourWebUrl) in a windows or console application changes are that you get the following error:

The web application at [URL] could not be found. Verify that you have typed the url correctly. If the url should be serving existing content, the system administrator may need to add a new request url mapping to the intended application.

Set project output to be .Net 3.5 and x64. If not it will fail when executing code!!!

If it works without x64 target it probably works on your dev environment but will fail in producion.

Enjoy…

3 thoughts on “The web application at [URL] could not be found

    • In your Visual Studio (in 2010) project, right-click on the project and select properties

      To change Target framework, select the Application tab (you will see the Target framework dropdown box). Set this to .Net 3.5.

      To change to x64 platform, select the Build tab and change Platform target (dropdown box) to x64 instead of default “Any CPU”.

Leave a comment