I am running the following SPSiteDataQuery. The query was working, but only started throwing the SPException after I added an already existing managed metadata site column to the Documents library. I'm not sure if this was the only change in the environment, but is all I can think of that's changed. I've since removed the site column from the library, and all documents in the library, but it is still throwing the exception.
To be clear, the query works when querying all lists (base type 0), but throws the SPException when querying libraries (base type 1):
var query = new SPSiteDataQuery {
Query = string.Format(@"<Where><Eq><FieldRef Name='TaxCatchAll' LookupId='TRUE' /><Value Type='Lookup'>{0}</Value></Eq></Where>", wssId),
Lists = string.Format("<Lists BaseType='{0}' />", baseType),
ViewFields = @"<FieldRef Name='ID' Nullable='TRUE' /><FieldRef Name='UniqueId' Nullable='TRUE' /><FieldRef Name='LinkFilename2' Nullable='TRUE' /><FieldRef Name='Title' Nullable='TRUE' Type='text' /><FieldRef Name='FileRef' Nullable='TRUE' /><FieldRef Name='EncodedAbsUrl' Nullable='TRUE' /><FieldRef Name='Resource_x0020_Types' Nullable='TRUE' /><FieldRef Name='FAQ_x0020_Category' Nullable='TRUE' />",
Webs = "<Webs Scope='SiteCollection'/>"
};
Here are the details of the exception:
[Microsoft.SharePoint.SPException]: {""}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
InnerException: {"<nativehr>0x80131904</nativehr><nativestack></nativestack>"}
Message: ""
Source: "Microsoft.SharePoint"
StackTrace: " at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)\r\n at Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns)\r\n at Microsoft.SharePoint.SPWeb.GetSiteData(SPSiteDataQuery query)\r\n at PROJ.DataAccess.RelatedContentDA.QuerySite(Int32 wssId, Int32 baseType)"
TargetSite: {Void HandleComException(System.Runtime.InteropServices.COMException)}