R – SPSite constructor problem “Operation aborted”

sharepointsharepoint-2007

Warning: I'm an asp.net developer taking my first steps in SharePoint.

So, i'm writing a console application that connects to a SharePoint Server 2007 site on the same machine, but it seems that something goes wrong during the call to SPSite() constructor. Here's the simplified code:

using (SPSite siteCollection = new SPSite("http://server/AwesomeSite"))
{

  //when i set a breakpoint on this line and inspect the siteCollection object, 
  //most of it's properties (for example siteCollection.AllWebs.Names) throw an 
  //exception, which leads me to the conclusion that something went wrong during 
  //the constructor above.

  SPWebCollection site = siteCollection.AllWebs;
  SPWeb web = site[""];
  SPList list = web.Lists["AwesomeList"]; //exception occurs here
}

The SPException text:

Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

I followed the advice of Sharepoint SPSite and checked that:

  1. The user is a server farm administrator.
  2. The user has Read and Write permissions on the content database.
  3. The user is a site collection administrator.
  4. The user has permissions to access the Windows SharePoint Services site or the SharePoint Server 2007 site through which the code iterates.

And they are all correct. What else could be causing this to happen?

Best Answer

In my experience, the SPSite() constructor is highly dependent on the Alternate Access Mappings configuration of your site. Make sure that the URL you are using in the constructor appears in the list of mappings (e.g., http vs. https, machine vs. FQDN).

Related Topic