Friday 24 June 2011

Error @ SPSite site = new SPSite()

I created a new console application using Visual Studio2010. The console application had only one single line of code.

using(SPSite site = new SPSite("http://myspsite2010"))
{
Console.Write(site.RootWeb.Title);
}


The error message I got when I debugged this simple console application is.

The Web application at 'http://myspsite2010' 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.

Solved:
Right-click on the project > Go to properties. In the properties dialog go to 'Build'. Under the 'General' section change the 'Platform target' to 'x64'.