# Getting “Cannot use the changeToken from one object against a different object” calling CrossListQueryCache

We have a custom web service hosed in the ISAPI\ folder. We are getting the SPSite of a different site collection in the same Web Application using the url (and making sure it is exposed after use). To Query lists content on that site collection we use the CrossListQueryCache.GetSiteData(SPSite, webUrl) overload. I have tried using list id and name but no difference. I have also tried to make a singleton, making sure we are using the same SPSite object through the lifetime of the process (thinking the error has to do with a "different" SPSite object).

The issue is that sometimes (often if there are rapid calls) I get a "Cannot use the changeToken from one object against a different object" exception in the GetSiteData call. I only see that I get the exception in debug mode, I think the exception is caught in the GetSiteData method and not logged in the ULS.

What is the reason for this exception, and how can I handle/Fix it? Or is this something that is handled by the SharePoint API?

 internal DataTable GetSiteCollectionQueryResult(SPSite site, string query, string listName, string viewFields, uint rowLimit)
{
var crossListQuery = new CrossListQueryInfo
{
UseCache = true,
Webs = @"<Webs Scope='SiteCollection' />",
RowLimit = rowLimit,
Query = query,
ViewFields = viewFields,
Lists = string.Format(@"<Lists Title='{0}' />", listName)
};

var crossListQueryCache = new CrossListQueryCache(crossListQuery);
var tbl = crossListQueryCache.GetSiteData(site, site.RootWeb.Url);
return tbl;
}

• After using reflection and trying to find the connection between SPChangeCollection.ValidateChangeToken and GetSiteData. I found that in CacheManager.CheckForChanges(SPSite) method has a cache that is setting a flag. I will give it a day then post this as the answer. – gaotter Dec 2 '13 at 16:14