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?
I have a Web API on the SharePoint server that we use as a medium to get data from our own database. This Web API was attempting to open the website, and I was receiving the same error. I had to make sure that the Application Pool identity being used had access to open the website.
I set the identity of the Web API application pool to SharePointServerFarm, which is the identity that my SharePoint web applications use.
Try Logging on as the Farm Admin account. Or, granting the required SQL Server Roles to the account you are using.
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.
Add-SPShellAdmin -UserName domain\username
did the trick for me. The documentation says that it adds user to the SharePoint_Shell_Access role in the farm configuration database only, and also ensures the user is added to the WSS_Admin_WPG local group on each server in the farm.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
failed, reporting the same error as the poster (even though it is reachable from a browser on the same machine). The following worked
I have yet to figure out why.