I have been trying to get my MVC C# code to connect to my sharepoint server. I have tried everything and I keep getting this error no matter what I try.
The Web application at [http://myserver/] 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.
This is my code:
string strUrl = "http://myserver/";
using (SPSite site = new SPSite(strUrl))
{
}
Make sure that you target your binary as 64-bit with .Net framework 3.5, otherwise it will throw this error. Also as other answers has stated; to use the object model like this require that the code is executed on a server in the farm.