Debugging Method 2: Debug a .csx file
- Last UpdatedJan 06, 2025
- 1 minute read
This method is easier than Debugging Method 1: Debug a .csx file because it has fewer steps, but it does require you to modify your .csx script.
As with Debug Method 1, you must have Visual Studio installed to use this method.
Debug a .csx file
-
From the place in your script that you want to break into the debugger, add the following line:
System.Diagnostics.Debugger.Break();
-
Run your script as usual. When this line is encountered, Windows notifies you that the process is expecting to be debugged and asks you which debugger you want to use.
Visual Studio should be one of the choices (or the only choice).
-
Select Visual Studio and tell it to continue.
Visual Studio opens and places you in the debugger at that point in your script.
-
Remove the line from step 1 after you're finished debugging your script. Otherwise, the debugger tries to open every time the script runs.