When using SharePoint 2010 Server OM code on a Windows 2008 64 bit server, you get below exception :
The Web application at http://servername:portnumber/sitename/ 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.
You are using a very simple code and the exception occurs at the very first line while opening new instance of an SPSite :
using (SPSite osite = new SPSite("http://blrs2r11-1c/")) { using (SPWeb oweb = osite.OpenWeb()) { // Response.Write(oweb.Title); Label1.Text = oweb.Title; } }
The solution is in your visual studio, change the target platform to 64 bit.
Update: Or you may not have permission to run the code.
