Thread
Author
Catastrophic failure when searching subsites
Post Follow-up to this message
Microsoft.SharePoint.SPException: Catastrophic failure ---> System.Runtime.InteropServices.COMException I am trying to write a web part that will return search results across all subsites within a site and have run into a strange error. I found questions about this error already posted in several newsgroups - but no solution :-( 1) I first get the current (root) web using the following line: SPWeb oRoot =SPControl.GetContextWeb(this.Context).Site.RootWeb; 2) I can then search the documents and lists by using the following lines: SPSearchResultCollection oRootDocResults = oRoot.SearchDocuments(SearchString); --> this works ok! 3) I now need to get all of the subsites that the current user has permissions to view and then I loop through all of these sites and call the method. This is where the problem occurs. SPWebCollection subSites = oRoot.GetSubwebsForCurrentUser(); SPSearchResultCollection oDocResults; for (int i=0;i<subSites.Count;i++) { oDocResults = subSites[i].SearchDocuments(SearchString); } When the method is called I get the following error: Microsoft.SharePoint.SPException: Catastrophic failure ---> System.Runtime.InteropServices.COMException I am at a loss as to why this is occuring. Any ideas or suggestions? I am really in a bind and need to get cross-site search running. Thanks in advance! Martin
Post Follow-up to this message
Martin
01-25-05 02:03 AM
Re: Catastrophic failure when searching subsites
Post Follow-up to this message
Hi Martin, I'm just guessing here, but what if you tried this: SPWebCollection subSites = oRoot.GetSubwebsForCurrentUser(); SPSearchResultCollection oDocResults; foreach (SPWeb searchWeb in subSites) { oDocResults = searchWeb.SearchDocuments(SearchString); } Does that help? Are you getting the error the first time trhough the loop, or the second? Keep in mind that the oDocResults is redefined each time through the loop; i.e. the results of the search are not added to the SPSearchResultCollection but replace them. -- _____________ Jim Duncan Collutions, Inc. "Martin" <martinREMOVE@advis.ch> wrote in message news:%23qMWMXz$EHA.3908@TK2MSFTNGP12.phx.gbl...
Post Follow-up to this message
Jim Duncan
01-25-05 02:03 AM
Re: Catastrophic failure when searching subsites
Hi Jim, Thank you but no, that doesn't help. The code I posted was from a first quick and dirty trial. What I really want to do is in VB and looks like this: Private Sub searchWeb(ByVal web As SPWeb, ByRef output As System.Web.UI.HtmlTextWriter) Dim subWeb As SPWeb Dim src As SPSearchResultCollection = web.SearchDocuments(SearchString) For Each sr As SPSearchResult In src 'Render out the search results... Next Dim subWebs As SPWebCollection = web.GetSubwebsForCurrentUser() For Each subWeb In subWebs searchWeb(subWeb, output) Next End Sub This works fine for the root web. But in the recursive iterations, the web.SearchDocuments(SearchString) throws the Catastrophic Failure exception... Any other ideas would be greatly appretiated! Martin "Jim Duncan" <CollutionsInc@community.nospam> wrote in message news:u1IAOC0$EHA.3368@TK2MSFTNGP15.phx.gbl...