Getting SPSite from ContentEnumerator

Sep 28, 2009 at 1:36 AM

This project gave me a great start to an overly complicated API (maybe SP2010 will be better).  Anyway, I'm trying to get to the SPSite from my ContentEnumerator and I'm getting...

System.IO.FileNotFoundException: The Web application at XXXXXX 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.
   at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
   at Microsoft.SharePoint.SPSite..ctor(String requestUrl)

I moved the same exact code into a console app and it works fine so I know it's not that.  I also printed the WindowIdentity it's running under and that looks good as well.  Is search running in some wierd context that doesn't allow access to SPSite or do I need to get to it from some search context?


Sep 28, 2009 at 6:53 AM

If you look at good SharePoint design you should not use the Object model from the search. This is because the default content access account should not have any database access rights.

SharePoint search works using the webservices (f.e. SiteData).

For your current proble, are you working with a prefix like mossph:// ?

Maybe this prefix is still in the url when opening a SPSite?

Sep 29, 2009 at 2:56 AM

Not sure why I can't get the SPSite. I went ahead and used the web services instead, thanks for the suggestion.