2

Always getting the following error while trying to create a spsite-object:

The Web application "http://myApplicationURL/" at 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.

The webservice should access the local SharePoint-Application which does work in a browser. First it seems like a common problem, but tried all the web-suggested solutions:

  • compiling as "any platform" or x64
  • using .Net 3.5
  • starting as farm administrator / don't start as farm administrator
  • trying the published version of the webservice instead of debugging in VS2010
  • modifying: regedit DisableLoopBackCheck to 1, means I'm able to log in locally to the application/the other applications
  • tried to access a different application on the same server -> same problem
  • used elevated privileges
  • starting VS2010 with "ADMIN"-Privileges
  • adding the starting user (is farm admin) to WSS_ADMIN_WPG windows user group
  • users are fully privileged on SQL content database
  • users are site collection as well

what else could be wrong?

Here some code, it's simple as that:

class Program
{
    static void Main(string[] args)
    {
        using (SPSite site = new SPSite("http://test-sharepoint.myApp.local"))
        {

        }
    }
}
3
  • Show us the code pls. Exception makes no sense either unless you manually retyped it : The Web application "myApplicationURL" >>> at <<< could not be found
    – Fox
    Jan 8, 2013 at 16:14
  • Also, another thing you're not mentioning above is whether you're executing account has Site collection rights. I know you're saying you're running as Farm Admin, but that DOES NOT give you Site col admin rights be default. Just make sure of this as well.
    – Fox
    Jan 8, 2013 at 16:16
  • I am also getting the SAME Error when I try to Use the same CODE in ASP.NET WebService , But the Same Piece of code able to Produce the Output in Sample Console Applciation. Why its behaving like this. ?
    – Akshay Joy
    Apr 18, 2013 at 7:28

2 Answers 2

2

I just had to set the AppPool for the WebService: I set it to the same AppPool that the SharePoint application had. It started to work immediately - even if the original AppPool does have the same configurations as the SP2010-AppPool has...

To debug the WebService, just connect the VisualStudio-Debugger to the w3wp.exe-process.

1

Excerpt from Stefan GoBner's Blog:

Here are the most common reasons this error can occur:

  1. The code is executed on a different machine - The SharePoint object model (except the Client API) requires to be run on the SharePoint server itself. It is not possible to run the application on a server which is not within the same SharePoint farm the code is trying to access.
    1. Insufficient Rights on the site collection - The code is executed in context of an account which does not have read permission on the site collection
    2. Incorrect Url being used - Verify that the site works correct in a browser and double check that the server is correct registered in the AAM settings
    3. Incorrect bitness - The SharePoint object model needs to be executed with the same bitness as the operating system. That means you cannot use the SharePoint object model in a 32-bit application if the Operating System and SharePoint are installed as 64-bit version. Ensure to compile the project using the correct bitness (64-bit on a 64-bit machine vs. 32-bit on a 32-bit machine)
    4. Incorrect .NET framework version - Ensure that the project is configured to use .NET 3.5. .NET 4.0 cannot be used with the current versions of SharePoint
11
  • Did you notice that I was talking about the SPSite-Object? I don't need the Service Reference for creating SPSite-Objects!
    – stromflut
    Jan 8, 2013 at 10:33
  • Do you have SharePoint installed on the machine that you are doing the development on?
    – Mike
    Jan 8, 2013 at 15:06
  • Yes exactly on the same machine...
    – stromflut
    Jan 8, 2013 at 15:14
  • I updated my answer.
    – Mike
    Jan 8, 2013 at 15:24
  • Please read my question carefully, all these points are already covered in the question!
    – stromflut
    Jan 8, 2013 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.