Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm getting this error when I Approve the Publishing Page. The workflow starts using WfMgr.StartWorkflow and the page enters "InProgress" State. And it waits for user to approve the page and Workflow waits on WorkflowItemChanged event. when user approve the page the workflow continues from the workflowitemchanged event. The custom code written in the activity runs fine and it seems that the workflow is complete. but it goes into "Error Occurred" state and following error is shown in the ULS logs.

Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.     at Microsoft.SharePoint.Library.SPRequestInternalClass.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     --- End of inner exception stack trace ---     at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     at Microsoft.SharePoint.SPEventReceiverDefinition.RegisterForWebOrList(Operation operation, Boolean isMigration)     at Microsoft.SharePoint.SPEventReceiverDefinition.Register(Operation operation, Boolean isMigration)     at Microsoft.SharePoint.SPEventReceiverDefinition.Delete()     at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.CommitDeleteSubscription(Transaction txn, Object[] transData)

Error in commiting pending workflow batch items: Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.     at Microsoft.SharePoint.Library.SPRequestInternalClass.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     --- End of inner exception stack trace ---     at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     at Microsoft.SharePoint.SPEventReceiverDefinition.RegisterForWebOrList(Operation operation, Boolean isMigration)     at Microsoft.SharePoint.SPEventReceiverDefinition.Register(Operation operation, Boolean isMigration)     at Microsoft.SharePoint.SPEventReceiverDefinition.Delete()     at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.CommitDeleteSubscription(Transaction txn, Object[] transData)     at Microsoft.SharePoint.Workflow.SPPendingWork.PerformWorkNow(Transaction txn)     at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.Commit(Transaction transaction, ICollection items)          

WinWF Internal Error, terminating workflow Id# c9e76fad-3003-4f58-b32e-f5733e7e428b             

System.Workflow.Runtime.Hosting.PersistenceException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.     at Microsoft.SharePoint.Library.SPRequestInternalClass.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     --- End of inner exception stack trace ---     at Microsoft.SharePoint.Library.SPRequest.RegisterEventReceiver(String bstrUrl, String bstrListName, EventReceiverOperation operation, Guid guidId, String bstrName, Guid guidSiteId, Guid guidWebId, Guid guidHostId, Int32 dwHostType, Int32 dwType, Int32 dwSequenceNumber, String bstrAssembly, String bstrClass, String bstrData, String bstrFilter, Int32 dwCredential, Guid contextObjectId, Guid contextType, Guid contextEventType, Guid contextId, Guid contextCollectionId)     at Microsoft.SharePoint.SPEventReceiverDefinition.RegisterForWebOrList(Operation operation, Boolean isMigration)     at Microsoft.SharePoint.SPEventReceiverDefinition.Register(Operation operation, Boolean isMigration)     at Microsoft.SharePoint.SPEventReceiverDefinition.Delete()     at Microsoft.SharePoint.Workflow.SPWinOESubscriptionService.CommitDeleteSubscription(Transaction txn, Object[] transData)     at Microsoft.SharePoint.Workflow.SPPendingWork.PerformWorkNow(Transaction txn)     at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.Commit(Transaction transaction, ICollection items)     at System.Workflow.Runtime.WorkBatch.PendingWorkCollection.Commit(Transaction transaction)     at System.Workflow.Runtime.WorkBatch.Commit(Transaction transaction)     at System.Workflow.Runtime.VolatileResourceManager.Commit()     at System.Workflow.Runtime.WorkflowExecutor.DoResourceManagerCommit()     at System.Workflow.Runtime.Hosting.WorkflowCommitWorkBatchService.CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback)     at System.Workflow.Runtime.Hosting.DefaultWorkflowCommitWorkBatchService.CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback)     at System.Workflow.Runtime.WorkflowExecutor.CommitTransaction(Activity activityContext)     at System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation)     --- End of inner exception stack trace ---     at System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation)     at System.Workflow.Runtime.WorkflowExecutor.System.Workflow.ComponentModel.IWorkflowCoreRuntime.PersistInstanceState(Activity activity)     at System.Workflow.ComponentModel.Activity.MarkClosed()     at System.Workflow.ComponentModel.Activity.ReleaseLockOnStatusChange(IActivityEventListener`1 eventListener)     at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.SafeReleaseLockOnStatusChange(ActivityExecutionContext context)     at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)     at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)     at System.Workflow.Runtime.Scheduler.Run()             

any ideas?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

As i mentioned earlier in the comment that the same code was working on one server and was not working on the other.

If fixed the issue by running the systemupdate command under elevated privileges.

so i replaced this code

workflowProperties.Item.Web.AllowUnsafeUpdates = true; 
workflowProperties.Item["myCol"] = my value""; 
workflowProperties.Item.SystemUpdate(false); 
workflowProperties.Item.Web.AllowUnsafeUpdates = false;

with this

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    using (SPSite site = new SPSite(workflowProperties.SiteId))
    {
         using (SPWeb web = site.OpenWeb())
         {
             web.AllowUnsafeUpdates = true;
             SPListItem Item = web.GetListItem(workflowProperties.Item.Url);
             Item["myCol"] = "";
             Item.SystemUpdate(false);
             web.AllowUnsafeUpdates = false;
         }
    }


 });

I don't know how but this fixed the problem I was having.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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