SharePoint error: Web application at xxxx could not be found

In a console application using visual studio 2012 it was changing the Target framework to 3.5 for me....


The account that is the identity of the app pool in my environment was already a member of WSS_ADMIN_WPG. I installed my web service locally. Using the external domain name such as

SPSite siteCollection = new SPSite(@"http://mydomain:123");

failed, reporting the same error as the poster (even though it is reachable from a browser on the same machine). The following worked

SPSite siteCollection = new SPSite(@"http://localhost");

I have yet to figure out why.


Change Target Platform to x64 as Sharepoint 2010 runs only in 64 bit mode


OK, after hours of pain i finally found the problem....

I had to add myself to the WSS_ADMIN_WPG group on the server. Hope this helps someone.