Setting Breakpoints with Debugger.Break()

If the static information provided by the Trace and Debug objects is not sufficient, you can set a breakpoint in your template and interactively debug the template's execution. To do this, insert a Debugger.Break() statement at the point where you would like to suspend the template's execution.

If your template is compiled in Debug mode and CodeSmith hits a Debugger.Break() statement, it will cease template execution and display the Just-In-Time Debugging dialog box:

Depending on the software installed on your computer and the applications that you have running, you may see a different selection of possible debuggers

The debugger you choose will open with the code for your CodeSmith template loaded. At that point, you can use all of the tools supplied by the selected debugger to step through code, examine variables, and so on.

Always save your templates before debugging them with this technique! When you stop debugging in the external debugger, CodeSmith Studio will be terminated.