How do I get Workflow Trace information to show in Visual Studio's Debug Window?
By using
Microsoft.Activities.Diagnostics.TraceTrackingParticipant (for WorkflowApplication and WorkflowInvoker) or
Microsoft.Activities.Diagnostics.WorkflowServiceTraceBehavior you can display tracking data in the Visual Studio Debug window. This gives you great visibility into exactly how your workflow is behaving.
For WorkflowApplication or WorkflowInvoker
Step 1: Add Microsoft.Activities to your project
Use NuGet to add to your project - for more see
How do I install Microsoft.Activities.Extensions?
Step 2: Add the TraceTrackingParticipant to the extensions collection
var invoker = new WorkflowInvoker(InvokeChildDefinition);
// Using Microsoft.Activities.TraceTrackingParticipant to output tracking to the VS Debug Window
invoker.Extensions.Add(new TraceTrackingParticipant());
invoker.Invoke();
For Workflow Services
Download
Windows Workflow Foundation (WF4) - WorkflowService Trace Behavior Sample
Step 1: Add Microsoft.Activities to your project
Use NuGet to add to your project - for more see
How do I install Microsoft.Activities?
Step 2: Add the WorkflowServiceTraceBehavior to your web.config
- Open Web.config
- Add the extension
- Add the behavior
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="workflowServiceTrace" type="Microsoft.Activities.Extensions.Diagnostics.WorkflowServiceTraceElement, Microsoft.Activities.Extensions" />
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- Other stuff here ....-->
<workflowServiceTrace />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Step 3: Run your service in the debugger
Now when you invoke your service in the debugger you will see exactly what is going on
