One of the things I’ve found useful in Biztalk development are debug statements. True, you can use the orchestration debugger and view the values of messages as the orchestration runs, but it can be a good bit easier to have the orchestrations write debug statements when they reach certain points. To accomplish this you can put calls to System.Diagnostics.Debug.WriteLine in the Expression and Message Assignment shapes and watch them using DebugView (which can be downloaded here).
For this example I’ve got a main orchestration that receives a loan request and another orchestration that determines if the loan is approved or not based on the credit score. Throughout both orchestrations we’ll write statements to indicate our current tasks.
In the Debug Statement expression shape below I’ve specified the following line of code:
And this is the Approval orchestration:
In this case the debug statements are embedded into the message assignment shapes.
After deploying these orchestrations, opening DebugView and submitting a few loans the following is displayed:
The statements can be as detailed as you wish to make them. The other thing worth pointing out is that calls to the System.Diagnostics.Debug library may be removed during compilation depending on the current compilation statement mode. If you want to be able to control whether or not the debug statements are written via a configuration file setting to debug something in a production environment, you may consider using System.Diagnostics.Trace.WriteLine instead, as these calls will not be removed during compilation.
Source code for this sample can be found here.