State Machine WF Service Instance crashes when I active tracing

Sep 19, 2012 at 7:52 PM

I have added Workflow Service Trace behavior in web.conf file and working state machine start generating exceptions when I test it with WCF client. 

I can see trace output in VS OUTPUT  window but in the end it crashes with following message; 

WorkflowInstance Aborted [XXXXXX] Reason "An error occurred while calling tracking participants causing the instance to be aborted.  See the inner exception for more details. InnerException Message: The given key was not present in the dictionary."

I have added following line web.config behavior extensions and <workflowServiceTrace/> tag in to service behaviors section.

<add name="workflowServiceTrace" type="Microsoft.Activities.Extensions.Diagnostics.WorkflowServiceTraceElement, Microsoft.Activities.Extensions"/> 

Any Idea?

Mar 22, 2013 at 2:27 PM
I am also receiving a similar error:

I have the settings in config
i.e. in the behavior extensions
<add name="workflowServiceTrace" type="Microsoft.Activities.Extensions.Diagnostics.WorkflowServiceTraceElement, Microsoft.Activities.Extensions" />,
in the behaviors
<workflowServiceTrace />
and in the system.diagnostics
<trace autoflush="false" indentsize="4">
  <listeners>
    <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
    <remove name="Default" />
  </listeners>
</trace>
I am using version 2.0.3.9 of the Microsoft.Activities.Extensions and just recently we have started to encounter the following message when using the service trace.

{"An error occurred while calling tracking participants causing the instance to be aborted. See the inner exception for more details."}

{An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.Activities.Hosting.WorkflowInstance.WorkflowInstanceControl.EndFlushTrackingRecords(IAsyncResult result)
at System.ServiceModel.Activities.Dispatcher.WorkflowServiceInstance.OnEndFlushTrackingRecords(IAsyncResult result)
at System.Activities.Runtime.WorkItem.OnTrackingComplete(IAsyncResult result)}

This was working but just recently this started, almost like some kind of Windows update may have changed something.
We are using the .net framework v4.0.30319
Mar 22, 2013 at 4:01 PM
I am also receiving a similar error:

I have the settings in config
i.e. in the behavior extensions
<add name="workflowServiceTrace" type="Microsoft.Activities.Extensions.Diagnostics.WorkflowServiceTraceElement, Microsoft.Activities.Extensions" />,
in the behaviors
<workflowServiceTrace />
and in the system.diagnostics
<trace autoflush="false" indentsize="4">
  <listeners>
    <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
    <remove name="Default" />
  </listeners>
</trace>
I am using version 2.0.3.9 of the Microsoft.Activities.Extensions and just recently we have started to encounter the following message when using the service trace.

{"An error occurred while calling tracking participants causing the instance to be aborted. See the inner exception for more details."}

{An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.Activities.Hosting.WorkflowInstance.WorkflowInstanceControl.EndFlushTrackingRecords(IAsyncResult result)
at System.ServiceModel.Activities.Dispatcher.WorkflowServiceInstance.OnEndFlushTrackingRecords(IAsyncResult result)
at System.Activities.Runtime.WorkItem.OnTrackingComplete(IAsyncResult result)}

This was working but just recently this started, almost like some kind of Windows update may have changed something.
We are using the .net framework v4.0.30319
May 2, 2014 at 12:06 AM
Edited May 2, 2014 at 12:07 AM
In my case, this was caused by a bug in the ReceiveMessageRecord.MessageId Property getter, in .NET 4.5 framework. But I also found bugs in Microsoft.Activities.Extensions that were terminating my workflows. I fixed a few, but soon tired of that - so I just added exception trapping around the main point of entry, in WorkflowServiceTraceBehavior.Track():
        protected override void Track(TrackingRecord record, TimeSpan timeout)
        {
            try
            {
                record.Trace();
            }
            catch (Exception e)
            {
                // Traces must never kill my Workflows, unless I want it to do so, for debugging purposes.
#if DEBUG
                Debugger.Break();
#endif
            }
        }
I'm not sure if that is the only point of entry, and there's probably a much better way to do this, but at least now I can see what's going on, and only my own bugs will cause my workflows to crash :)

HTH