Skip to content

Debugging

QueryStorm does not currently have a built-in debugger, but there are two static methods that can help with debugging: Log() and Debug().

YOUTUBE

The Log() method

The simplest way to debug issues is to use the Log(object obj) method to print values to the messages pane.

The Log() method is contained in the QueryStorm.Core.DebugHelpers class. All class files that QueryStorm generates have a static using directive for that class, so you can use the Log method anywhere in your code, without qualifying it with the namespace or the class name.

It's important to note that QueryStorm has two log viewers. One is part of the IDE, and the other is part of the Runtime (launched separately from the ribbon). The output of the Log() method will be visible in both places, so Runtime users will be able to see these messages.

Attaching a debugger

The Log() method is useful, but quite often a proper debugger is needed to track down tricky bugs. QueryStorm compiles code in a debugger-friendly way, so it's fairly easy to debug your code with an external debugger.

To launch a debugger at a particular location in the source code, use the Debug() method. The Debug() method is also available anywhere in the code without prefixing it with the namespace or the class name, due to the using directive that's part of all code files scaffolded by QueryStorm.

If the local machine has Visual Studio installed, the Debug() method will launch Visual Studio, attach it to the process and stop the debugger at the current line. If a debugger is already attached, it will simply stop at the line with the Debug() call.

If you do not have Visual Studio installed, you can use the small open-source DNSpy debugger, attach it to the Excel process, and use the Debug() method to stop the debugger at the desired line in the code.