1

Timer job suddnely started failing with below error

Site Enumeration Stack: at Microsoft.SharePoint.Administration.SPSiteCollection.get_Item(Int32 index)   at OTIS.AR.EmailTimerJob.EmailTimerJob.Execute(Guid targetInstanceId)    

Earlier it was working correctly

     SPWebApplication webApp = this.Parent as SPWebApplication;
        using (SPSite oSite = new SPSite(webApp.Sites[0].Url))
        {
            using (SPWeb oWeb = oSite.RootWeb)
            {}}

Above is the code used to access SPweb object.

Update 1:

my suspect is error is in below line

 List<SPListItem> lstCollStatementItems = new List<SPListItem>();
            foreach (SPListItem itm in CollStatementItems)
            {
                lstCollStatementItems.Add(itm);
            }

stack trace : System.Runtime.InteropServices.COMException: Cannot complete this action.  Please try again., StackTrace:   
 at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()    
 at Microsoft.SharePoint.SPListItemCollection.get_Count()
  • You haven't supplied the error. Please expand upon your post; what is the actual error, what does this job do, what is the full code, etc. – Trevor Seward Jun 7 '18 at 14:58
0

I found the cause of the error, the reason was result of CAML query was invalid. If CAML query has invalid character it will not fail while returning the result instead when we operate on the result.

In my code I was checking the cound of the collectoin

CollStatementItems.Count

and there is failed with error "Cannot complete this action."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.