After running into the problem 'Catastrophic failure during SPWeb.SearchDocuments' described by Patrick here, I investigated a little further.
I used SQL Profiler to trace the queries to the SharePoint Server and a litte test application to invoke the following code:
"Failing code" Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://192.168.2.63:150/"); Microsoft.SharePoint.SPWeb web = site.AllWebs[new Guid("{BC758E66-1975-4DBF-A641-4931F62BE87E}")]; web.SearchDocuments("KeyWord");
Summary of executed stored procedures:
... procedures for getting the site... (are the same on both code blocks so irrelevant)
...AllWebs...
No stored procedures executed.
...SearchDocuments... exec sp_oledb_ro_usrname select collationname(0x0904100000)
"Successfull code"
Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://192.168.2.63:150/"); Microsoft.SharePoint.SPWeb web = site.OpenWeb(new Guid("{BC758E66-1975-4DBF-A641-4931F62BE87E}")); web.SearchDocuments("KeyWord");
Summary of executed stored procedures:
... procedures for getting the site... (are the same on both code blocks so irrelevant)
...OpenWeb...
exec proc_GetTpWebMetaDataAndListMetaData '6E09C07B-696A-4573-AC39-F421CD1C8922', N'Locations', NULL, 0, 1, 0x010500000000000515000000863F405F46596E99ACD89A01F4010000
...SearchDocuments... exec sp_oledb_ro_usrname select collationname(0x0904100000)
So the difference is than web executing OpenWeb method the stored procedure "proc_GetTpWebMetaDataAndListMetaData" is executed. This procedures seems to get some information about the specified Web.
To get some more information I modified the failing code as follows:
Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://192.168.2.63:150/"); Microsoft.SharePoint.SPWeb web = site.AllWebs[new Guid("{BC758E66-1975-4DBF-A641-4931F62BE87E}")]; int i = web.Folders.Count; web.SearchDocuments("KeyWord");
Executed stored procedures on Folders.Count line:
exec proc_GetTpWebMetaDataAndListMetaData '6E09C07B-696A-4573-AC39-F421CD1C8922', N'Locations', NULL, 0, 1, 0x010500000000000515000000863F405F46596E99ACD89A01F4010000
So as we can see the Folders.Count line executes the same procedure as the OpenWeb does. My conclusion would be that it is just a simple bug: OpenWeb is never called when accessing Webs via AllWebs property.
To confirm this I modified the successfull code as folows:
Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://192.168.2.63:150/"); Microsoft.SharePoint.SPWeb web = site.OpenWeb(new Guid("{BC758E66-1975-4DBF-A641-4931F62BE87E}")); web.Close(); web.SearchDocuments("KeyWord");
This leads to the same "Microsoft.SharePoint.SPException: Catastrophic failure" exception.
Conclusion:
Patrick's workaround is the way to go. Hopefully SP1 will fix the bug.
7:29:05 PM
|