SharePoint error: Web application at xxxx could not be found

54,901

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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

Solution 5

In my case, I re-opened Visual Studio 2012 running as Administrator, and the problem is solved.

Share:
54,901
Abe Miessler
Author by

Abe Miessler

Software Engineer who works with Javascript/Node.js, Python, C#, Go, SQL Server, MongoDB, MySQL and a whole lot more. I enjoy learning new technologies when they are the best tool for the job. I usually fill the role of a full stack engineer but always seem to enjoy working with data the most. 80th recipient of the Gold SQL badge 50th recipient of the Gold SQL Server badge Hobbies include web application security and machine learning.

Updated on July 09, 2022

Comments

  • Abe Miessler
    Abe Miessler almost 2 years

    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?

  • Abe Miessler
    Abe Miessler over 13 years
    Gave it a shot but no dice. I think this only applies to 401.1 errors, which isn't what i'm getting, correct?
  • chapluck
    chapluck over 11 years
    There is option in Sharepoint: Alternate access mapping. May be you need to add external domain there. technet.microsoft.com/en-us/library/…
  • Lzh
    Lzh about 10 years
    +1 Maybe because localhost automatically maps to current server, on which you are running the script targetting it. As in the hosts file (but no need for hosts file)
  • Force
    Force over 9 years
    This was the same for me except I was running in a Windows Forms App. I was porting over existing code to a new project that happened to be .Net 4.5 and it wouldn't return the site. Changing it to 3.5 resolved the issue; I wonder if this is because we are on SharePoint 2010?