OnTaskChange is not running<p> </p> <p>I have created a sequential workflow in Visual Studio 2005, and the tasks are created inside the workflow (CreateTask), and then updated from a custom ASPX form. The problem is that the OnTaskChanged event does not execute when the task is updated.This was working OK, but now it does not fire. The Task is definitely updated, since I change the status and add comments. Further, I also found that if I change the task inside SharePoint UI, then the OnTaskChange code is run.</p> <p> </p> <p>I did check the Logs, and found the following error message. Is it possible that the SharePoint server and Workflow engine are out of synch? I have restarted the server, but still the problem remains.</p> <p> </p> <p>I would appreciate any suggestions to resolve this.</p> <p> </p> <p> </p> <p>04/11/2007 11:45:55.24  w3wp.exe (0x17DC)   x1590 Windows SharePoint Services    General </p> <p> </p> <p>ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads. <br>ThreadId = 6, Free call stack =    at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request)     at Microsoft.SharePoint.SPSite.Close()     <br>at Microsoft.SharePoint.SPSite.Dispose()     <br>at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)     <br>at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange)     <br>at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.ItemAdded(SPItemEventProperties properties)     <br>at Microsoft.SharePoint.SPEventManager.RunItemEventReceiver(SPItemEventReceiver receiver, SPItemEventProperties properties, SPEventContext context, String receiverData)    <br> at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, Object properties, SPEventContext context, String receiverData)     <br>at Microsoft.SharePoint.SPEventManager.&lt;&gt;c__DisplayClass8`1.&lt;InvokeEventReceivers&gt;b__0()     <br>at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)     <br>at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)     <br>at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, CodeToRunElevated code)     <br>at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPUserToken userToken, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)     <br>at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](Byte[] userTokenBytes, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)     <br>at Microsoft.SharePoint.SPEventManager.HandleEventCallback[ReceiverType,PropertiesType](Object callbackData)    <br>at Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(Object state)     <br>at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)     <br>at System.Threading.ExecutionContext.runTryCode(Object userData)<br>at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)<br>at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)<br>at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br>at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)  , Allocation call stack (if present) null  <br></p>© 2009 Microsoft Corporation. All rights reserved.Thu, 03 Sep 2009 23:47:44 Z77fa0116-6e45-4ff8-a252-4e8cbb7e5d6chttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#77fa0116-6e45-4ff8-a252-4e8cbb7e5d6chttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#77fa0116-6e45-4ff8-a252-4e8cbb7e5d6cSteve4042322http://social.msdn.microsoft.com/Profile/en-US/?user=Steve4042322OnTaskChange is not running<p> </p> <p>I have created a sequential workflow in Visual Studio 2005, and the tasks are created inside the workflow (CreateTask), and then updated from a custom ASPX form. The problem is that the OnTaskChanged event does not execute when the task is updated.This was working OK, but now it does not fire. The Task is definitely updated, since I change the status and add comments. Further, I also found that if I change the task inside SharePoint UI, then the OnTaskChange code is run.</p> <p> </p> <p>I did check the Logs, and found the following error message. Is it possible that the SharePoint server and Workflow engine are out of synch? I have restarted the server, but still the problem remains.</p> <p> </p> <p>I would appreciate any suggestions to resolve this.</p> <p> </p> <p> </p> <p>04/11/2007 11:45:55.24  w3wp.exe (0x17DC)   x1590 Windows SharePoint Services    General </p> <p> </p> <p>ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads. <br>ThreadId = 6, Free call stack =    at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request)     at Microsoft.SharePoint.SPSite.Close()     <br>at Microsoft.SharePoint.SPSite.Dispose()     <br>at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)     <br>at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange)     <br>at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.ItemAdded(SPItemEventProperties properties)     <br>at Microsoft.SharePoint.SPEventManager.RunItemEventReceiver(SPItemEventReceiver receiver, SPItemEventProperties properties, SPEventContext context, String receiverData)    <br> at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, Object properties, SPEventContext context, String receiverData)     <br>at Microsoft.SharePoint.SPEventManager.&lt;&gt;c__DisplayClass8`1.&lt;InvokeEventReceivers&gt;b__0()     <br>at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)     <br>at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)     <br>at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, CodeToRunElevated code)     <br>at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPUserToken userToken, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)     <br>at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](Byte[] userTokenBytes, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)     <br>at Microsoft.SharePoint.SPEventManager.HandleEventCallback[ReceiverType,PropertiesType](Object callbackData)    <br>at Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(Object state)     <br>at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)     <br>at System.Threading.ExecutionContext.runTryCode(Object userData)<br>at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)<br>at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)<br>at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br>at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)  , Allocation call stack (if present) null  <br></p>Wed, 11 Apr 2007 09:15:31 Z2007-04-11T09:15:31Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#178fbe35-3a66-49b1-8a93-dcdd6abf7884http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#178fbe35-3a66-49b1-8a93-dcdd6abf7884Simon Doyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Simon%20DoyOnTaskChange is not running<p>Steve,</p> <p>Just a thought has the CreateTask and OnTaskChange activity got the same colleration token specified for the task?</p> <p> </p> <p>Regards</p> <p>Simon</p>Wed, 11 Apr 2007 14:13:19 Z2007-04-11T14:13:19Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#2f80e780-eb9c-4ba2-8666-13036d94df43http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#2f80e780-eb9c-4ba2-8666-13036d94df43Steve4042322http://social.msdn.microsoft.com/Profile/en-US/?user=Steve4042322OnTaskChange is not running<p>Hi Simon,</p> <p> </p> <p>Yes. They share the same token, and I checked they are at the same scope. But you are correct, this is the connection between the task and onchange handler. I will create a more simple workflow to determine if the problem is inside my WF, or an external factor. I will let you know the result.</p>Wed, 11 Apr 2007 14:33:36 Z2007-04-11T14:33:36Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#1a795b51-c294-4e83-8e68-df12961d893dhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#1a795b51-c294-4e83-8e68-df12961d893dSimon Doyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Simon%20DoyOnTaskChange is not running<p>Steve,</p> <p>I have seen this before with one of my workflows but I also had a problem with my development environment. After I updated my environment the problem disappeared. Not that I think they are related - but thought I'd mention just in case.</p> <p> </p> <p>Simon</p> <p> </p> <p> </p>Wed, 11 Apr 2007 15:15:32 Z2007-04-11T15:15:32Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#67d281e9-65d1-4824-ad23-a0dabbb0c078http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#67d281e9-65d1-4824-ad23-a0dabbb0c078herve.delannoyhttp://social.msdn.microsoft.com/Profile/en-US/?user=herve.delannoyOnTaskChange is not runningHello<br>I have the same problem...<br><br>I tried to build my own workflow with aspx initiation and association forms. My workflow is just composed by an activity : a createTask Activity. Association form works fine, but i never see the instanciation form... And the create task activity makes an error. See below the code and the logs.<br><br>Could anyone help me? thanks a lot for any answer !<br><br> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p>workflow.xml :<br>...<br>&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;<br>&lt;Workflow<br>Title=&quot;Demo Sample&quot;<br>Name=&quot;WF Sample&quot;<br>Description=&quot;Demo Sample Description.&quot;<br>Id=&quot;A475....525763&quot;<br>CodeBesideClass=&quot;WF_Test.Workflow1&quot; <br>CodeBesideAssembly=&quot;WF_Test, Version=3.0.0.0, Culture=neutral, PublicKeyToken=d2e8f...66bdb1&quot;<br>AssociationUrl=&quot;../_layouts/work/assoc_form.aspx&quot;<br>InstantiationUrl=&quot;../_layouts/work/inst_form.aspx&quot;<br>&gt;<br>&lt;Categories/&gt;<br>&lt;/Workflow&gt;<br>&lt;/Elements&gt;</p></div></div><br><br><br>Logs :<br><br> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p>System.InvalidOperationException: Correlation value on declaration &quot;workflowToken&quot; is already initialized. <br>ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads. </p></div></div><br>Element of answer are here :<br>http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1553658&amp;SiteID=17&amp;mode=1<br>Thu, 03 May 2007 09:17:25 Z2007-05-03T09:17:25Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#16d97413-e462-4986-a6f6-2bf90647bbe0http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#16d97413-e462-4986-a6f6-2bf90647bbe0PraveenBattulahttp://social.msdn.microsoft.com/Profile/en-US/?user=PraveenBattulaOnTaskChange is not runningmake sure that workflow correlation token and create task correlation token are different<br><br>for create task,  correlation token needs to be created, but not workflowToken<br><br>thanks <br>praveen<br>Mon, 14 May 2007 13:15:08 Z2007-05-14T13:15:08Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#78799ea0-1b23-4b0d-860d-47a06f07f09chttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#78799ea0-1b23-4b0d-860d-47a06f07f09cCDamhttp://social.msdn.microsoft.com/Profile/en-US/?user=CDamOnTaskChange is not running<p>Hello, </p> <p> </p> <p>I've got the same problem than Steve....</p> <p> </p> <p>It's not a correlation token problem because my workflow works well when I made my tasks modifications using Sharepoint UI!</p> <p> </p> <p>However, as soon as I'm trying to update my task using specific code outside &quot;Workflow code&quot;, the event OnTaskChanged is not fired....</p> <p> </p> <p>Many thanks for your help!</p>Mon, 14 May 2007 13:45:10 Z2007-05-14T13:45:10Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#6112641d-9f7e-4419-9289-9082eb889b21http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#6112641d-9f7e-4419-9289-9082eb889b21Rodrigo Díaz Conchahttp://social.msdn.microsoft.com/Profile/en-US/?user=Rodrigo%20D%u00edaz%20ConchaOnTaskChange is not running<p>I had the same issue but I've resolved it using the <strong>SPWorkflowTask.AlterTask() </strong>method  and not the SPWorkflowTask.Update() itself.</p> <p> </p> <p>Hope this help!</p>Mon, 14 May 2007 22:39:13 Z2007-05-14T22:39:13Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#6c6ee2fc-2adc-4e20-ac2a-71c29b9d2e28http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#6c6ee2fc-2adc-4e20-ac2a-71c29b9d2e28CDamhttp://social.msdn.microsoft.com/Profile/en-US/?user=CDamOnTaskChange is not running<p>Hello, </p> <p> </p> <p>Unfortunately, I've already tried to use SPWorkflowTask.AlterTask() instead of Update() method....</p> <p>and it hasn't worked....</p> <p> </p> <p>Looking for others solutions...</p> <p> </p> <p>Thanks</p>Tue, 15 May 2007 07:06:25 Z2007-05-15T07:06:25Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4215da2a-9e91-41f3-8257-0bf9f920f173http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4215da2a-9e91-41f3-8257-0bf9f920f173KevinHouhttp://social.msdn.microsoft.com/Profile/en-US/?user=KevinHouOnTaskChange is not running<p>I'm also getting this error.  However, my workflow is even simpler than those described here.  My workflow has a createTask activity and a Code activity, and a logToHistoryListActivity activity.  The workflow compeletes successfully but this error is still in the log files.  Anyone know why?</p> <p> </p> <p>Thanks,<br>Kevin</p>Thu, 17 May 2007 16:14:16 Z2007-05-17T16:14:16Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#ef62ba52-3960-494c-b42b-f169545bcdaehttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#ef62ba52-3960-494c-b42b-f169545bcdaePraveenBattulahttp://social.msdn.microsoft.com/Profile/en-US/?user=PraveenBattulaOnTaskChange is not runningmake sure that in your designer.cs class <span style="color:rgb(255,102,0)">workflow token</span> defined twice or initialized twice.<br><br>thanks<br>praveen<br>Fri, 18 May 2007 04:44:23 Z2007-05-18T04:44:23Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#0686a06c-e847-4f4e-94c2-e0ba978876cbhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#0686a06c-e847-4f4e-94c2-e0ba978876cbKevinHouhttp://social.msdn.microsoft.com/Profile/en-US/?user=KevinHouOnTaskChange is not running<p>Praveen,</p> <p> </p> <p>Thanks for helping me.  I looked in my designer.cs file and found only one reference to my workflow token: <font size=2></p> <p> </p> <p>correlationtoken2.Name = </font><font color="#800000" size=2>&quot;workflowToken&quot;</font><font size=2>;</font></p> <p><font size=2><font size=3></font></font> </p> <p><font size=2><font size=3>How or where do I define it a second time as you suggest.  Also, this is designer generated code, if it needs to be in there twice, shouldn't the designer do it for me?</font></font></p> <p><font size=2><font size=3></font></font> </p> <p><font size=2><font size=3>Kevin</font></p></font>Fri, 18 May 2007 13:59:30 Z2007-05-18T13:59:30Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#ba982307-e0ab-4a38-b582-6b3444702deehttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#ba982307-e0ab-4a38-b582-6b3444702deeMaycon Carrazedohttp://social.msdn.microsoft.com/Profile/en-US/?user=Maycon%20CarrazedoOnTaskChange is not running<p> </p> <p><font size=2>Hi,</font></p> <p><font size=2></font> </p> <p><font size=2>I´m having this problem with a State Machine Workflow, the token is the same to the Create Task and OnTaskChanged actions, but the workflow just finish without erros in the WSS, instead of wait the task change. </font></p> <p><font size=2></font> </p> <p><font size=2>// Code that create the Token and assing in the CreateTask action</font></p> <p><font size=2>correlationtoken4.Name = <font color="#800000">&quot;AnaliseJuridicoToken&quot;</font>;</font></p> <p><font size=2>correlationtoken4.OwnerActivityName = <font color="#800000">&quot;stateAnaliseJuridico&quot;</font>;</font></p> <p><font size=2>this.createTaskWithContentType1.CorrelationToken = correlationtoken4;</font></p> <p><font size=2></font> </p> <p><font size=2>// Code that assing the Token tho the OnTaskChanged</font></p> <p><font size=2><font color="#0000ff">this</font>.onTaskAJChanged.CorrelationToken = correlationtoken4;</font></p> <p><font size=2></font> </p> <p><font size=2>Even if I change the Initial State to another one, the problem persist. </font></p> <p><font size=2></font> </p> <p><font size=2>Any idea?</font></p> <p><font size=2></font> </p> <p><font size=2>Tank´s.</font></p>Fri, 18 May 2007 18:56:26 Z2007-05-18T18:56:26Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#34ae35e4-5395-4410-bf2e-66714697c2dehttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#34ae35e4-5395-4410-bf2e-66714697c2deRoDo777http://social.msdn.microsoft.com/Profile/en-US/?user=RoDo777OnTaskChange is not running<p>I had the same problem.</p> <p align=left> </p> <p align=left>And my mistake was, to create different correlationTokes for the task.</p> <p align=left> </p> <p align=left>I've done this because i choose the wrong OwnerActivityName at OnTaskChanged.</p> <p align=left>( i choose ActEvtDrivenOnTask01Changed instead of the top WF activity WF02)</p> <p align=left>When I wanted to compile i got &quot;The correlation token for Activity createTask01 has an </p> <p align=left>owner activity name which is not its parent&quot;.</p> <p align=left>So I created another one.</p> <p align=left> </p> <p align=left>If you choose the name of the WF itself in OwnerActivityName for both then everything is fine again</p> <p align=left>:-)</p> <p align=left><font face=Arial size=2></font> </p>Mon, 24 Sep 2007 14:42:53 Z2007-09-24T14:42:53Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#74677539-f610-410a-986d-c8ccabf0e3aahttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#74677539-f610-410a-986d-c8ccabf0e3aaSomak Bhattacharyyahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somak%20BhattacharyyaOnTaskChange is not running<p align=left><font face=Arial size=2>For all those people who are facing this issue, can you please check the following two things in your code:</font></p> <ol> <li> <div align=left>The Correlation Tokens are fine, i.e.; the same token passes through &quot;Create Task&quot; --&gt; &quot;On Task Created&quot; --&gt; &quot;On Task Changed&quot; --&gt; &quot;On Task Completed&quot;.</div> <li> <div align=left>If the above is fine, do check the method that is getting invoked by each of these activities. For example,<br>&quot;Create Task&quot; should invoke the CreateTask_MethodInvoking(or your custom function name) and &quot;On Task Changed&quot; should OnTaskChanged_MethodInvoking(or your custom method name) so on and so forth. Try to find out if all these activities are mapped one to one to their functions and there is no cross connections like &quot;OnTaskChanged&quot; invokes the function that is being called by &quot;OnTaskCreated&quot; etc.</div> <li> <div align=left>If you have created a new Correlation Token for your task, make sure that you are calling your own Correlation Token. Also make sure that the &quot;OwnerActivityName&quot; should always be your workflow name. In case you have renamed your Workflow from the default &quot;Workflow1&quot; then make sure that the custom name is in place for all the Correlation Tokens!</div> <li> <div align=left>Also check that all your activities point to the same Task ID. That is should point to the Task ID you have given to your &quot;Create Task&quot; activity. I would suggest you to visit the following sites:<br><a title="http://weblog.vb-tech.com/nick/archive/2007/02/25/2207.aspx" href="http://weblog.vb-tech.com/nick/archive/2007/02/25/2207.aspx">http://weblog.vb-tech.com/nick/archive/2007/02/25/2207.aspx</a><br><a title="http://weblog.vb-tech.com/nick/archive/2007/03/05/2241.aspx" href="http://weblog.vb-tech.com/nick/archive/2007/03/05/2241.aspx">http://weblog.vb-tech.com/nick/archive/2007/03/05/2241.aspx</a><br>for a really great Walkthrough. Or alternatively you may want to visit <a title="http://www.sheltonblog.com/" href="http://www.sheltonblog.com/">http://www.sheltonblog.com/</a> for a real wealth of resources and Video. Just search for it inside the site and you'll find tremendous amount of information.<br></div></li></ol> <p align=left>Doing the above steps should solve your problem if it is not any environmental issue! <img src="http://forums.microsoft.com/MSDN/WebResource.axd?d=NySzF1eivP_rMoc50GQJzcvS4MHMOEKwYrCIgDtzuzlw7GsNki3H_INlfYaLgkxFdA4ESFRtesEUXj11MHjIL5WMBvm3Pubiu_iWcnqAaGQ1&amp;t=633337194230757564"></p>Fri, 25 Apr 2008 21:00:59 Z2008-04-25T21:00:59Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#6cece697-1c7b-48af-9b8a-130af9d3e3dehttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#6cece697-1c7b-48af-9b8a-130af9d3e3demattdannahttp://social.msdn.microsoft.com/Profile/en-US/?user=mattdannaOnTaskChange is not running<p align=left><font face=Arial size=2></font> </p> <p>Somak,</p> <p align=left> </p> <p align=left>In 3. you said to make sure the OwnerActivityName was the name of the Workflow.  Would this still be the case if your onTaskChanged eventwas inside a SequentialActivity.  Would the SequentialActivity name be the OwnerActivityName?  I am having the same problem but only periodically.  It seems like it's losing the event handler somehow and I need to fix it asap.</p> <p align=left> </p> <p align=left>Thanks in advance,</p> <p align=left>Matt</p>Fri, 27 Jun 2008 19:23:55 Z2008-06-27T19:23:55Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#11d13c08-b800-4ac1-a4fd-6482c2e59911http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#11d13c08-b800-4ac1-a4fd-6482c2e59911Somak Bhattacharyyahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somak%20BhattacharyyaOnTaskChange is not running<p align=left><span style="font-family:Arial;font-size:x-small">Hey Matt,</span></p> <p align=left> </p> <p align=left>Sorry for the late reply. Since your Workflow is failing only intermittently, and is working as expected otherwise, I don't think there is a problem with your Correlation Tokens, OwnerActivityName, TaskID etc.. Are you being able to reproduce the issue? Is it occurring only in some special cases? Or is the behaviour random? If you send me your <strong>code</strong> and the <strong>SharePoint Log files</strong> (under 12\logs) containing the error text, I can look through it. And may be in best case we can track the error. <img src="http://forums.microsoft.com/Forums/WebResource.axd?d=NySzF1eivP_rMoc50GQJzcvS4MHMOEKwYrCIgDtzuzlw7GsNki3H_INlfYaLgkxFdA4ESFRtesEUXj11MHjIL5WMBvm3Pubiu_iWcnqAaGQ1&amp;t=633337194230757564" alt=""></p> <p> </p> <p align=left>You can mail me at <a title="mailto:somak.bhattacharyya@live.com" href="mailto:somak.bhattacharyya@live.com">somak.bhattacharyya@live.com</a>.</p> <p align=left> </p> <p align=left>Thanks and Regards,</p> <p align=left>Somak.</p>Wed, 02 Jul 2008 12:58:26 Z2009-05-13T17:00:42Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#0da5777f-6f7e-4f05-9038-bcf746de8063http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#0da5777f-6f7e-4f05-9038-bcf746de8063CiBiaRhttp://social.msdn.microsoft.com/Profile/en-US/?user=CiBiaROnTaskChange is not running<p>Hello,<br><br>I've been following this thread since the beginning because I'm exeperiencing same problems as Steve, herve.delannoy, CDam and others.<br><br>I have created a sequential workflow in Visual Studio 2008 to use it on a MOSS server to manage documents added to a Document library. A variable number of tasks are created inside the workflow thru a Replicator activity in the way shown in the following outline:<br><br>    OnWorkflowActivated<br>    (...)<br>    1.1  SequenceActivity<br>    1.1.1  Replicator<br>    1.1.1.1  Sequence<br>    1.1.1.1.1  CreateTaskWithContentType<br>    1.1.1.1.2  While<br>    1.1.1.1.2.1      Sequence<br>    1.1.1.1.2.1.1        OnTaskChanged<br>    1.1.1.1.2.1.2        If(Condition)<br>    1.1.1.1.2.1.2.1           UpdateTask<br>    1.1.1.1.3  CompleteTask<br>    1.1.1.1.4  LogToHistoryListActivity</p> <p>Tasks are updated from a custom ASPX form thru SPWorkflowTask.AlterTask method with a code block like this being executed when user clicks Approve button:<br><br>    SPSite lGlobalSite = SPControl.GetContextSite(Context);<br>    SPWeb lSite = lGlobalSite.OpenWeb();<br>    string lParamSPListGuid = Request.Params[&quot;List&quot;];<br>    string lParamTaskListItemID = Request.Params[&quot;ID&quot;];</p> <p>    SPListItem lTaskListItem = lSite.Lists[new Guid(lParamSPListGuid)].GetItemById(System.Convert.ToInt16(lParamTaskListItemID));<br>    SPList lTaskListAttachedTo = lSite.Lists[new Guid(lParamSPListGuid)];<br>    Guid lWorkflowInstanceGuid = new Guid(Convert.ToString(lTaskListItem[&quot;WorkflowInstanceID&quot;]));</p> <p>    Hashtable lTaskHash = new Hashtable();<br>    lTaskHash[&quot;_ApprovalNotes&quot;] = txtApprovalNotes.Text;<br>    lTaskHash[&quot;_ApprovalStatus&quot;] = aApprove;</p> <p>    lSite.Dispose();</p> <p>    SPWorkflowTask.AlterTask(lTaskListItem, lTaskHash, false);</p> <p>    SPUtility.Redirect(lTaskListAttachedTo.DefaultViewUrl, SPRedirectFlags.UseSource, HttpContext.Current);<br><br><br>Once  the button is clicked, task should be updated and the workflow awakened with a OnTaskChanged event where custom code updates Document Library’s custom column values, as shown bellow:<br><br>    NumTasksCompleted++;</p> <p>    Guid statusFieldID = workflowProperties.TaskList.Items[0].Fields[&quot;Approval Form Status Field&quot;].Id;<br>    this._taskApprovalStatus = System.Convert.ToBoolean(onTaskChanged2_AfterProperties1.ExtendedProperties[statusFieldID]);</p> <p>    if (this._taskApprovalStatus)<br>    {<br>       NumTasksApproved++;<br>    }</p> <p>    Guid notesFieldID = workflowProperties.TaskList.Items[0].Fields[&quot;Approval Form Notes Field&quot;].Id;</p> <p>    if (onTaskChanged2_AfterProperties1.ExtendedProperties[notesFieldID] != null)<br>    {<br>        _approverNotes = onTaskChanged2_AfterProperties1.ExtendedProperties[notesFieldID].ToString();<br>    }</p> <p>    this._taskCompleted = true;<br><br><br>The problem is that although task's notes and status are always updated, OnTaskChanged event does not always execute in my workflow after user clicks Approve button.<br><br>The problem does not happen after a given number of workflows executed/completed or a given number of tasks created/assigned. Workflow can work flawlessly more than 10 times, creating and assigning about 60 tasks in total and allowing me to complete them all. But maybe next time I start it, everything stops working after clicking Approve button on the ASPX form that approves a task. Even worse, it happens more often in the actual server where workflow is installed than in the almost identical virtual machine used as test environment.<br><br>When this happens, Redirect method send the browser back to Task list where the task shows 'Not Started' under Status column, and document library shows 'In progress' status for my workflow. Sometime, after waiting several minutes and/or restarting IIS, some of that tasks get completed, but most of them don't, and trying to re-approve them results in a 'This task is currently locked by a running workflow' exception.<br><br>I've been looking for a solution to this behavior for weeks, and tried almost every suggestion I've found to date –including Somak Bhattacharyya's as of April 25-, but nothing seems to fix it.<br><br>Lately, after making some changes in the workflow and keeping an eye on SharePoint log files and system Event viewer, I've noticed the following exception being thrown some minutes after workflow stops working<br><br>    &quot;Error loading and running event receiver Microsoft.SharePoint.Workflow.SPWinOEItemEventReceiver<br>     in Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c.<br>    Additional information is below.</p> <p>    : Thread was being aborted.&quot;<br><br><br>And the corresponding log file content<br><br>AppDomainUnloadListener.Stop(False) called. ShutdownReason=HostingEnvironment, this=15368010<br>AppDomainUnloadListener.Stop() entered lock(this=15368010)<br>AppDomainUnloadListener.Stop() about to AcquireWriterLock(), this.countdownSeconds=120<br>AppDomainUnloadListener.Stop() finally{} block with (timedOut == false), ensured that all LRO thread finished<br>Unregistered hosting environment for ID CMSCACHE1764382194<br>AppDomainUnloadListener.Stop(False) called. ShutdownReason=HostingEnvironment, this=15368010<br>AppDomainUnloadListener.Stop() entered lock(this=15368010)<br>AppDomainUnloadListener.Stop() about to AcquireWriterLock(), this.countdownSeconds=120<br>AppDomainUnloadListener.Stop() finally{} block with (timedOut == false), ensured that all LRO thread finished<br>Unregistered hosting environment for ID CMSCACHE1521652287<br>Unregistered hosting environment for ID CMSCACHE233053084<br>AppDomainUnloadListener.Stop(False) called. ShutdownReason=HostingEnvironment, this=23011038<br>AppDomainUnloadListener.Stop() entered lock(this=23011038)<br>AppDomainUnloadListener.Stop() about to AcquireWriterLock(), this.countdownSeconds=120<br>AppDomainUnloadListener.Stop() finally{} block with (timedOut == false), ensured that all LRO thread finished<br>Entering MRU trim routine.<br>Initial table size: 89040640 in 383 entries<br>Final table size: 89040640 in 383 entries<br>Exiting MRU trim routine.<br>Initial table size: 89040640 in 383 entries<br>Final table size: 89040640 in 383 entries<br>Exiting MRU trim routine.<br>RunWorkflow: System.Threading.ThreadAbortException: Thread was being aborted.     at System.Threading.WaitHandle.WaitOneNative(SafeWaitHandle waitHandle, UInt32 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)     at System.Threading.WaitHandle.WaitOne(Int64 timeout, Boolean exitContext)     at System.Threading.WaitHandle.WaitOne(TimeSpan timeout, Boolean exitContext) at Microsoft.SharePoint.Workflow.SPWorkflowInstanceBase.WaitUntilInstanceIdle(TimeSpan timeout) at Microsoft.SharePoint.Workflow.SPWorkflowHostServiceBase.WaitUntilInstanceIdle(SPWorkflowInstance workflow, TimeSpan timeOut)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow originalWorkflow, SPWorkflow workflow, Collection`1 events, SPRunWorkflowOptions runOptions)<br>System.Threading.ThreadAbortException: Thread was being aborted.     at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow originalWorkflow, SPWorkflow workflow, Collection`1 events, SPRunWorkflowOptions runOptions)<br>Now terminating ULS (w3wp.exe, Microsoft.Office.Server.Native.dll)<br>Now terminating ULS (w3wp.exe, onetnative.dll)<br>Error loading and running event receiver Microsoft.SharePoint.Workflow.SPWinOEItemEventReceiver in Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Additional information is below.  : Thread was being aborted.<br>Now terminating ULS (w3wp.exe, Microsoft.Office.Server.Native.dll)<br>Now terminating ULS (w3wp.exe, onetnative.dll)<br><br><br>Once the exception happens, workflow status in document library is 'Error occurred' and I’m not able to get any other new instance of my workflow to work as expected. However, other workflows already installed in the server –but in other document libraries- work without any problem.<br><br>By the way, I have a version of my workflow and a set of log files ready to send to anyone willing to have a look at them. As I’ve run almost out of ideas, any help will be greatly appreciated.<br><br><br>Thanks in advance<br><br>Ramon</p>Thu, 14 Aug 2008 08:09:50 Z2008-08-14T08:44:25Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#3e43a023-b064-498a-9ae9-9065554a4807http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#3e43a023-b064-498a-9ae9-9065554a4807NoWirezhttp://social.msdn.microsoft.com/Profile/en-US/?user=NoWirezOnTaskChange is not running I thought I would add myself to the list here. My problem seems nearly identical to CiBiaR, except I am not even using a custom task form. The problem DOES seem random (between builds) and an additional detail I have not seen posted here would be the following:<br><br> <ol> <li>Workflow starts and creates task</li> <li>If the problem task is edited, the changes made in the UI show up in sharepoint just fine; however, the task is now locked by sharepoint and nothing after OnTaskCreated (including the OnTaskCreated_Invoked method) will fire.</li> <li>At this point, the entire workflow seems to become disconnected from sharepoint meaning: if any other tasks were created in parallel, editing them now results in the same total unresponsiveness / locking (even if the normally work just fine when completed ahead of the problem task).</li></ol> <p>I HAVE gone through my designer.cs code and verified that the task token is not being recreated or duplicated.<br><br>Example:<br>------<br></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">this</font><font style="font-size:11px">.OnTaskCreated_CreateADAccount.CorrelationToken = correlationtoken20;   </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">this</font><font style="font-size:11px">.OnTaskCreated_CreateADAccount.Executor = </font><font style="color:blue">null</font><font style="font-size:11px">;   </font></td></tr> <tr> <td></font><font style="color:blue">this</font><font style="font-size:11px">.OnTaskCreated_CreateADAccount.Name = </font><font style="color:blue">&quot;OnTaskCreated_CreateADAccount&quot;</font><font style="font-size:11px">;  </font></td></tr> <tr> <td style="background-color:#f7f7f7"> </td></tr></tbody></table></div> <p><br>------<br><br>correlationtoken20 is used for OnTaskCreated, OnTaskChanged, etc...<br><br>An excerpt from my ULS log:<br>Engine RunWorkflow: System.Workflow.Activities.EventDeliveryFailedException: Event &quot;OnTaskCreated&quot; on interface type &quot;Microsoft.SharePoint.Workflow.ITaskService&quot; for instance id &quot;6074c83e-d0ce-4de7-add4-2abf84f0a5ad&quot; cannot be delivered. ---&gt; System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.Workflow.SPWorkflowHostServiceBase.LoadInstanceData(Guid instanceId, Boolean&amp; compressedData)     at Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId)     at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)     at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)     at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)     at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)     --- End of inner exception stack trace ---     at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)     at Microsoft.SharePoint.Workflow.SPWinOETaskService.RaiseEvent(SPWinOeWorkflow workflow, SPWorkflowEvent workflowEvent, Object workItem, IPendingWork workHandler)     at Microsoft.SharePoint.Workflow.SPWinOeHostServices.Send(SPWinOeWorkflow winoeworkflow, SPWorkflowEvent e)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)</p>Tue, 26 Aug 2008 20:58:24 Z2008-08-26T20:58:24Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#e21a1835-7155-4047-940b-19b580e367dehttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#e21a1835-7155-4047-940b-19b580e367demfalthhttp://social.msdn.microsoft.com/Profile/en-US/?user=mfalthOnTaskChange is not runningWe had the same problem for weeks, and then we implemented the following advice from Somak Bhattacharyya (Microsoft) that did our day!<br><br><font color="#1f497d"><font color="#1f497d"><font face=calibri>Cross-verify that all the ID like TaskIDs etc. (GUIDs) that you are using in your Workflow code are generated runtime (e.g.; by using Guid.NewGuid() in C#) and are not set (hard-coded) in the code during development. <br></font></font></font><br>We have been able to finish off the delivery but are now left wondering how it can be that the lack of dynamic task IDs results in random problems that only show up in some environments whereas other environments run just fine. This makes troubleshooting very hard and suggests an environment problem at first glance. When you know what the problem is it all feels logical but when faced with a mysterious, random problem it is not that evident.<br><br>Good luck to all you others who are fighting with this one!<br><br>/Magnus Mon, 06 Oct 2008 12:36:49 Z2008-10-06T12:36:49Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#112d15ca-f4e9-4337-8420-93d14de775f6http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#112d15ca-f4e9-4337-8420-93d14de775f6mj14http://social.msdn.microsoft.com/Profile/en-US/?user=mj14OnTaskChange is not running  I am having the same problem.<br><br>It is a very very simple sequential workflow - cannot get simpler than this. Still, OnTaskChange event is not getting fired.<br>I can even send the project file for the workflow, if someone is willing to review it. But there is not option for attachment.<br><br>Its very basic workflow with  CreateTask -&gt; OnTaskCreate -&gt;CompleteTask . That is it. <br><br>I have<br>1. Separate Correlation token for workflow and activity<br>2. CreateTask, OnTaskCreate, CompleteTask have same correlation token and share same taskId.<br><font color="#0000ff" size=2> <p>Here is the code below. </p> <p>namespace PermWorkFlow</p> <p>{<br>public sealed partial class Workflow1: SharePointSequentialWorkflowActivity<br>{</p> <p>public Workflow1()<br>{<br>InitializeComponent();<br>}</p> <p>public Guid workflowId = default(System.Guid);<br>public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();<br>public Guid taskId = default(System.Guid);</p> <p>private void onTaskCreated1_Invoked(object sender, ExternalDataEventArgs e)</p> <p>{<br>SetTaskItemContributor(workflowProperties.TaskList, (e as SPTaskServiceEventArgs).afterProperties);<br>}</p> <p>private void SetTaskItemContributor(SPList taskList, SPWorkflowTaskProperties taskProps)<br>{</p> <p>SPListItem listItem = taskList.Items.GetItemById(taskProps.TaskItemId);<br>SPRoleDefinition roleDefinition = listItem.Web.RoleDefinitions.GetByType(SPRoleType.Contributor);<br>SPGroup group = listItem.Web.Groups[@&quot;Something\players&quot;];</p> <p>SPRoleAssignment roleAssignment = new SPRoleAssignment(group);<br>roleAssignment.RoleDefinitionBindings.Add(roleDefinition);</p> <p>if (!listItem.HasUniqueRoleAssignments)<br>{<br>listItem.BreakRoleInheritance(false);<br>}</p> <p>listItem.RoleAssignments.Add(roleAssignment);<br>listItem.Update();<br>}</p> <p>private void createTask1_MethodInvoking(object sender, EventArgs e)<br>{<br>taskId = Guid.NewGuid();<br>}</p> <p>}</p> <p>}</p> <p>Please let me if anyone willing to review the workflow project.</font></p>Fri, 24 Oct 2008 21:53:04 Z2008-10-24T21:53:04Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4f757506-baac-4bdf-a279-266a60e2d773http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4f757506-baac-4bdf-a279-266a60e2d773kukehttp://social.msdn.microsoft.com/Profile/en-US/?user=kukeOnTaskChange is not runningMy code uploads multiple files which kicks off an auto-start workflow on each item and sometimes one will randomly fail. I followed Somak's advice above and didn't get find anything wrong. (The Workflow is a State Machine and one of the first steps is to create a task).<br/> <br/> I initially thought it only happened when I was debugging, however further investigation reveals that this error does indeed occur randomly. <br/> <br/> I note that in the workflow code (I didn't write it), it initialises the Task ID (GUID) in the &quot;onWorkflowActivated_MethodInvoking&quot; method, so I'm wondering if this could be the cause. I usually initialise a Task's GUID in the &quot;createTask_MethodInvoking&quot; method.<br/> <br/> Current thoughts:<br/> <ul> <li>Change when the Task GUID gets set </li> <li>... if that fails:</li> <li>Manually start workflow for each item after upload process</li> <li>Wait 1 second between uploads</li> <li>Write another Timer Job which monitors if workflows succeed and if not, terminate and manually restart</li> </ul> Any advice appreciated.<br/> ----------<br/> Here's the error:<br/> <br/> <p class=MsoNormal style="line-height:normal"><span style="font-size:8pt;font-family:'Arial','sans-serif'">04/28/2009 19:19:19.14 w3wp.exe (0x1098)                                0x0F24 Windows SharePoint Services   General                                   0          Unexpected      ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads. ThreadId = 12, Free call stack =    at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request)     at Microsoft.SharePoint.SPSite.Close()     at Microsoft.SharePoint.SPSite.Dispose()     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.ItemAdded(SPItemEventProperties properties)     at Microsoft.SharePoint.SPEventManager.RunItemEventRe...         </span> <span style="font-size:10pt;font-family:'Times New Roman','serif'"></span></p> <p class=MsoNormal style="line-height:normal"><span style="font-size:8pt;font-family:'Arial','sans-serif'">04/28/2009 19:19:19.14* w3wp.exe (0x1098)                                0x0F24 Windows SharePoint Services   General                                   0          Unexpected      ...ceiver(SPItemEventReceiver receiver, SPItemEventProperties properties, SPEventContext context, String receiverData)     at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, Object properties, SPEventContext context, String receiverData)     at Microsoft.SharePoint.SPEventManager.&lt;&gt;c__DisplayClass8`1.&lt;InvokeEventReceivers&gt;b__0()     at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)     at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)     at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, CodeToRunElevated code)     at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPUserToken userToken, RunEventReceiver runEventReceiver, Ob... </span> <span style="font-size:10pt;font-family:'Times New Roman','serif'"></span></p> <p class=MsoNormal style="line-height:normal"><span style="font-size:8pt;font-family:'Arial','sans-serif'">04/28/2009 19:19:19.14* w3wp.exe (0x1098)                                0x0F24 Windows SharePoint Services   General                                   0          Unexpected      ...ject receivers, Object properties, Boolean checkCancel)     at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](Byte[] userTokenBytes, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)     at Microsoft.SharePoint.SPEventManager.HandleEventCallback[ReceiverType,PropertiesType](Object callbackData)     at Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(Object state)     at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)     at System.Threading.ExecutionContext.runTryCode(Object userData)     at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)     at System.Threading.ExecutionContext.RunInternal(Exec...      </span> <span style="font-size:10pt;font-family:'Times New Roman','serif'"></span></p> <p class=MsoNormal style="line-height:normal"><span style="font-size:8pt;font-family:'Arial','sans-serif'">04/28/2009 19:19:19.14* w3wp.exe (0x1098)                                0x0F24 Windows SharePoint Services   General                                   0          Unexpected      ...utionContext executionContext, ContextCallback callback, Object state)     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)     at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)     at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)  , Allocation call stack (if present) null     </span> <span style="font-size:10pt;font-family:'Times New Roman','serif'"></span></p>Wed, 29 Apr 2009 00:36:09 Z2009-04-29T07:25:44Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#b31f4c14-47db-4a70-b794-cee4c917d372http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#b31f4c14-47db-4a70-b794-cee4c917d372Somak Bhattacharyyahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somak%20BhattacharyyaOnTaskChange is not runningHere's a comprehensive list of all the things that you may want to verify whenever you face some unwanted and mystic issues with SharePoint Workflows.<br/><br/> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">I’ll give some random suggestions (Please understand that I am firing blankly here because I am not very sure of the issue that you are facing, i.e.; the failure point). These are arranged in decreasing order of probability:</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">1.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">Cross-verify that all the ID like TaskIDs etc. (GUIDs) that you are using in your Workflow code are generated runtime (e.g.; by using Guid.NewGuid() in C#) and are not set (hard-coded) in the code during development.</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">2.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">You are not having any concurrency/lock issues because of which your Workflow is failing to update some values somewhere down your code line. If yes, then make your code burn through the lock (this should be done using utmost care). Please try searching MSDN/ Live for good examples of how to go about doing this.</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">3.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">Are any Custom Event Receivers active on the List/Library you are attaching the Workflow to? If yes, make sure that you are not facing an occasional Code clash with it. For example, you are trying to do an update() from your Workflow Code and you are handling the same conditionally in your Event Receiver code, which fails and both sink together.</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">4.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">Use SPListItem.SystemUpdate() instead of the Update() method. They work differently. Please refer to MSDN for further clarification. You may also want to look at the SPListItem.SystemUpdate(false).</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt"><span style="">5.<span style="font:7pt 'Times New Roman'">     </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-family:Calibri;font-size:small">If you suspect a particular section of your code is causing the issue, try running that block with elevated privileges using:<br/></span></span><span style="font-family:'Tahoma','sans-serif';font-size:10pt">SPSecurity.RunWithElevatedPrivileges(delegate()</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">{</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">    // implementation details omitted</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">});</span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt"><span style="">6.<span style="font:7pt 'Times New Roman'">     </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-family:Calibri;font-size:small">Together with Point#5 above, try setting the CatchAccessDeniedException property of the SPSecurity class before you delegate with elevated privileges to false, like:<br/></span></span><span style="font-family:'Tahoma','sans-serif';font-size:10pt">bool originalCatchValue = SPSecurity.CatchAccessDeniedException;SPSecurity.CatchAccessDeniedException = false;</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">try</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">{</span></p> <p class=MsoNormal style="text-indent:0.5in;margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt"> SPSecurity.RunWithElevatedPrivileges(delegate()</span></p> <p class=MsoListParagraph style="text-indent:0.5in;margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">{</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">            // implementation details omitted</span></p> <p class=MsoListParagraph style="text-indent:0.5in;margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">});</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">}</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">finally</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">{</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">   SPSecurity.CatchAccessDeniedException = originalCatchValue;</span></p> <p class=MsoListParagraph style="margin:0in 0in 0pt 0.5in"><span style="font-family:'Tahoma','sans-serif';font-size:10pt">}<br/><strong>Note</strong>: For both points# 5 and 6 above you may have to run user accessible code with raised privileges. Please ensure Security and take a sign off from your Security Team regarding any vulnerabilities you may unknowingly create in the process.</span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">7.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">I had once faced problems with my custom Workflow when I wasn’t ticking the “Start the Workflow when a new item is created” option the workflow wasn't kicking at all and went into some sort of perpetual sleep. Try ticking that. You may need to change your code design/flow for this.</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">8.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">Try setting the workflow/task job timer to a low value, say every minute instead of the default 5 mins. Please verify that this or any custom job you may have created is not causing any hiccups.</span></span></span></p> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style=""><span style="font-family:Calibri;font-size:small">9.</span><span style="font:7pt 'Times New Roman'">       </span></span></span><span style="color:#1f497d" lang=EN-IN><span style="font-size:small"><span style="font-family:Calibri">Please verify that all your Code is marked to be serializable. By all I mean all your Workflow Code as well as all the custom classes that your code may be referring etc.<span style="color:#1f497d" lang=EN-IN><span style=""><span style="font:7pt &quot;Times New Roman&quot;">       </span></span></span><span style="color:#1f497d" lang=EN-IN> </span> <p class=MsoListParagraph style="text-indent:-0.25in;margin:0in 0in 0pt 0.5in"><span style="color:#1f497d" lang=EN-IN><span style="">10.<span style="font:7pt &quot;Times New Roman&quot;">   </span></span></span><span style="color:#1f497d" lang=EN-IN>Check if you are getting any exception in your Activity Level which you are handling and you are not throwing back. Lay man's explanation(not technical): SharePoint will never know of this exception, but it will face the same internal exception because all SharePoint processes are essentially asynchronous. So although it gets the exception, it doesn’t know what to do with it and gets puzzled. This may also be the case if you are leaving any exceptions unhandled making SharePoint go crazy. Just re-scan through your exception handling mechanism once more. Just once more.</span></p> </span></span></span></p><hr class="sig">Somak MSFTWed, 13 May 2009 16:57:59 Z2009-05-13T16:57:59Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#ccd7cdbd-bcd8-4e3f-bf2d-aea865c59ce3http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#ccd7cdbd-bcd8-4e3f-bf2d-aea865c59ce3kukehttp://social.msdn.microsoft.com/Profile/en-US/?user=kukeOnTaskChange is not running<span style="font-size:8pt;font-family:'Arial','sans-serif'">We are still getting the &quot;ERROR: request not found in the TrackedRequests&quot; error at random times on our State Machine workflow. <br/> <br/> Is there any specific advice on how to fix this error?</span>Wed, 24 Jun 2009 02:26:53 Z2009-06-24T02:26:53Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4f5abc1f-b53b-46ba-8980-a6b39f45997fhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4f5abc1f-b53b-46ba-8980-a6b39f45997fkukehttp://social.msdn.microsoft.com/Profile/en-US/?user=kukeOnTaskChange is not runningAdditionally, we are receiving a ThreadAbortException when we try to bulk approve tasks (i.e. enumerate tasks for this workflow and call AlterTask on each item):<br/> <br/> <p class=MsoPlainText>System.Threading.ThreadAbortException: Thread was being aborted.<br/> <span>   </span> at System.Threading.Thread.SleepInternal(Int32 millisecondsTimeout)<br/> <span>   </span> at Microsoft.SharePoint.Workflow.SPWorkflowTask.AlterTask(SPListItem task, Hashtable htData, Boolean fSynchronous)</p>Thu, 25 Jun 2009 04:58:51 Z2009-06-25T04:59:06Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4eefb2a1-b103-4784-8944-2f9819aa36a1http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#4eefb2a1-b103-4784-8944-2f9819aa36a1David S 17http://social.msdn.microsoft.com/Profile/en-US/?user=David%20S%2017OnTaskChange is not runningI am also experiencing the same issue. I have developed a state machine workflow using VS 2008 that has been in production and working for some months now and completes successfully the majority of the time, although I have just found a small number of tasks that have been updated with the onTaskChanged event not firing.<br/> <br/> Hopefully someone will be able to work out the cause of this as I need to get it working 100% of the time!<br/> <br/> Any info appreciated.<br/> <br/> Thanks<br/> <br/> DavidFri, 03 Jul 2009 05:38:44 Z2009-07-03T05:38:44Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#debb1641-24a2-49ea-b576-a97f7fdac1c2http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#debb1641-24a2-49ea-b576-a97f7fdac1c2PaulSmithLondonhttp://social.msdn.microsoft.com/Profile/en-US/?user=PaulSmithLondonOnTaskChange is not runningWe are experiencing the same problem using a Nintex workflow.  What I am not sure of is what it actually means in practice.  The workflow seems on the whole to be doing what we want - although we think there may be some random errors.<br/><br/>Surely someone at Microsoft must have a better idea what is happening here with so many people getting this error?Fri, 03 Jul 2009 10:54:44 Z2009-07-03T10:54:44Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#5715e567-0e1a-41e7-93cd-43760a429e2ahttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#5715e567-0e1a-41e7-93cd-43760a429e2aYonatannhttp://social.msdn.microsoft.com/Profile/en-US/?user=YonatannOnTaskChange is not running<p>I'm facing similar bahaviour. Developing custom WF with VS 2008, my CreateTaskWithContentType, OnTaskChanged and OnTaskCompleted have the same correlation token, the WF can work just fine for hours, then suddenly the onTaskChanged is not firing at all. When trying to access that task later - it is locked. <br/>I'm having similar log entries as those provided by other users above. What's killing me is the inconsistency style of this error, it happens in different places in the WF (I have different blocks of task assigning and listening), and occurs randomly.<br/><br/>Since so many are complaining about this issue, clearly everyone's code is correct (since the WF run successfully most of the time), Can someone from MS have a look at this issue or provide some tool to check what is going on behind?</p><hr class="sig">...Mon, 13 Jul 2009 14:27:41 Z2009-07-13T14:27:41Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#36e7aeec-7fa5-4e60-9884-c7571a16ee93http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#36e7aeec-7fa5-4e60-9884-c7571a16ee93W0uterhttp://social.msdn.microsoft.com/Profile/en-US/?user=W0uterOnTaskChange is not runningSame problem here. The majority (&gt; 90%) of the workflows run as expected but some get stuck.<br/>I've build quite a few complex workflows for clients. This is the first time I encounter the problem. Luckily it's on our own intranet.<br/><br/>I added logging at the start and end of every method in my workflow.<br/>When it gets stuck it is always after (successfully) invoking the method on the 'CreateTask' Activity.<br/><br/>The next activity is a 'LogToHistory' activity but his method never gets invoked. <br/><br/>It seems that the workflow engine never gets the 'event/command' to execute the next activity in the workflow.<br/><br/>Below you find the error that I find in my MOSS logs<br/><br/>Regards<br/>W<br/><br/><br/>RunWorkflow: System.ArgumentException: Item has already been added. Key in dictionary: '193ccecc-4d0c-4cf5-b80d-8e9364ae79f4'  Key being added: '193ccecc-4d0c-4cf5-b80d-8e9364ae79f4'     at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)     at System.Collections.Hashtable.Add(Object key, Object value)     at System.Collections.Hashtable.SyncHashtable.Add(Object key, Object value)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.TrackCreatedInstance(Guid trackingId, SPWorkflow workflow)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow originalWorkflow, SPWorkflow workflow, Collection`1 events, SPRunWorkflowOptions runOptions)  <br/>AutoStart Workflow: System.ArgumentException: New instances of this workflow template are currently disallowed.     at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflowElev(SPListItem item, SPFile file, SPWorkflowAssociation association, SPWorkflowEvent startEvent, Boolean bAutoStart, Boolean bCreateOnly)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)  <br/>ERROR: request not found in the TrackedRequests. We might be creating and closing webs on different threads. ThreadId = 8, Free call stack =    at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request)     at Microsoft.SharePoint.SPSite.Close()     at Microsoft.SharePoint.SPSite.Dispose()     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.ItemAdded(SPItemEventProperties properties)     at Microsoft.SharePoint.SPEventManager.RunItemEventRec...  <br/>...<br/>Thu, 03 Sep 2009 12:55:12 Z2009-09-03T12:55:12Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#0e5c59b3-01c1-4e59-89d8-72e9ad28633chttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#0e5c59b3-01c1-4e59-89d8-72e9ad28633cJeetshttp://social.msdn.microsoft.com/Profile/en-US/?user=JeetsOnTaskChange is not running<p>We exactly had the same problem &amp; resolved this issue by. <br/>Replacing OnTaskCreated activity with OnTaskChanged activity<br/>Create a  event receiver &quot;ItemAdded&quot; attached to the Task List and include the code as given blow.</p> <pre>public override void ItemAdded(SPItemEventProperties properties){try{SPWorkflowTask.AlterTask(properties.ListItem, null, false);}catch (Exception ex){Helper.GetExMessage(ex);}}</pre> <p><span style="font-size:x-small">This will execute the OnTaskChanged activity &amp; the workflow will treat this activity exactly same as OnTaskCreated activity. <br/>Using task object properties one can retrieve any task item fields.<br/>Make sure you, you execute the same piece of code on OnTaskChanged activity as you doing on OnTaskCreated activity.<br/><br/>I tried All the proposed Microsoft fixes &amp; none of them worked, but after a few trials I realized OnTaskChanged activity can do the required job.<br/><br/>Hope this helps!!!</span></p>Thu, 03 Sep 2009 23:44:40 Z2009-09-03T23:44:40Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#90b61f06-68a6-40b5-b380-daf27c431189http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/77fa0116-6e45-4ff8-a252-4e8cbb7e5d6c#90b61f06-68a6-40b5-b380-daf27c431189Jeetshttp://social.msdn.microsoft.com/Profile/en-US/?user=JeetsOnTaskChange is not running<blockquote>I thought I would add myself to the list here. My problem seems nearly identical to CiBiaR, except I am not even using a custom task form. The problem DOES seem random (between builds) and an additional detail I have not seen posted here would be the following:<br/><br/><ol> <li>Workflow starts and creates task </li> <li>If the problem task is edited, the changes made in the UI show up in sharepoint just fine; however, the task is now locked by sharepoint and nothing after OnTaskCreated (including the OnTaskCreated_Invoked method) will fire. </li> <li>At this point, the entire workflow seems to become disconnected from sharepoint meaning: if any other tasks were created in parallel, editing them now results in the same total unresponsiveness / locking (even if the normally work just fine when completed ahead of the problem task).</li> </ol> <p>I HAVE gone through my designer.cs code and verified that the task token is not being recreated or duplicated.<br/><br/>Example:<br/>------</p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" border=0 cellspacing=0 cellpadding=0> <colgroup span=1><col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap" span=1></colgroup> <tbody> <tr> <td><span>this</span><span style="font-size:11px">.OnTaskCreated_CreateADAccount.CorrelationToken = correlationtoken20;   </span></td> </tr> <tr> <td style="background-color:#f7f7f7"><span>this</span><span style="font-size:11px">.OnTaskCreated_CreateADAccount.Executor = </span><span>null</span><span style="font-size:11px">;   </span></td> </tr> <tr> <td><span>this</span><span style="font-size:11px">.OnTaskCreated_CreateADAccount.Name = </span><span>&quot;OnTaskCreated_CreateADAccount&quot;</span><span style="font-size:11px">;  </span></td> </tr> <tr> <td style="background-color:#f7f7f7"> </td> </tr> </tbody> </table> </div> <p><br/>------<br/><br/>correlationtoken20 is used for OnTaskCreated, OnTaskChanged, etc...<br/><br/>An excerpt from my ULS log:<br/>Engine RunWorkflow: System.Workflow.Activities.EventDeliveryFailedException: Event &quot;OnTaskCreated&quot; on interface type &quot;Microsoft.SharePoint.Workflow.ITaskService&quot; for instance id &quot;6074c83e-d0ce-4de7-add4-2abf84f0a5ad&quot; cannot be delivered. ---&gt; System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.Workflow.SPWorkflowHostServiceBase.LoadInstanceData(Guid instanceId, Boolean&amp; compressedData)     at Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId)     at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)     at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)     at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)     at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)     --- End of inner exception stack trace ---     at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)     at Microsoft.SharePoint.Workflow.SPWinOETaskService.RaiseEvent(SPWinOeWorkflow workflow, SPWorkflowEvent workflowEvent, Object workItem, IPendingWork workHandler)     at Microsoft.SharePoint.Workflow.SPWinOeHostServices.Send(SPWinOeWorkflow winoeworkflow, SPWorkflowEvent e)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)</p> </blockquote> <p>We exactly had the same problem &amp; resolved this issue by. <br/>Replacing OnTaskCreated activity with OnTaskChanged activity<br/>Create a  event receiver &quot;ItemAdded&quot; attached to the Task List and include the code as given blow.</p> <pre>public override void ItemAdded(SPItemEventProperties properties){try{SPWorkflowTask.AlterTask(properties.ListItem, null, false);}catch (Exception ex){Helper.GetExMessage(ex);}}</pre> <p><span style="font-size:x-small">This will execute the OnTaskChanged activity &amp; the workflow will treat this activity exactly same as OnTaskCreated activity. <br/>Using task object properties one can retrieve any task item fields.<br/>Make sure you, you execute the same piece of code on OnTaskChanged activity as you doing on OnTaskCreated activity.<br/><br/>I tried All the proposed Microsoft fixes &amp; none of them worked, but after a few trials I realized OnTaskChanged activity can do the required job.<br/><br/>Hope this helps!!!</span></p> <br/>Thu, 03 Sep 2009 23:47:04 Z2009-09-03T23:47:04Z