When I try to execute this code:
SPSite siteCollection = new SPSite(@"http://sp-devxxx:10000/");
It throws the following error:
The Web application at http://sp-devxxx:10000 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.
I can hit this site from my web browser, it is compiling in x64, my account has read/write access to the content db, the code is running on the server that the site is running on and there exists an access mapping for this site. Why would it be throwing this error?
In my case, I re-opened Visual Studio 2012 running as Administrator, and the problem is solved.
Had the same issue while running my code as "exe" file. Problem solved by running
cmd
as administrator. Hope this help someone.In case the user's account is already a member of
WSS_ADMIN_WPG
and still the issue persists, As mentioned by Tim.Try the following steps:
Any CPU
from the drop down.It resolved the problem for our console Application.
Have you disabled the loopback check?
http://sptwentyten.wordpress.com/2010/03/06/disable-the-loopback-check-via-powershell/
http://www.jeremytaylor.net/2010/05/24/sharepoint-disable-loopback-check-disableloopbackcheck-dword-in-registry/
In a console application using visual studio 2012 it was changing the Target framework to 3.5 for me....
In my case, I needed to add the user db_owner permission to the SharePoint_Config, SharePoint_AdminContent and WSS_Content databases, following the suggestions in this blog.