Tips for CIL debugging: No variables displayed

Because AX 2012 sometimes executes CIL generated from X++ instead of X++ itself, debugging must be done in a debugger that understands CIL and it almost always means Visual Studio. AX developers sometimes complain about the need of switching between two debuggers, that loading of symbols for debugging is slow and so on. Although these concerns are valid for the time being (things will change in AX7), using Visual Studio for debugging AX code also offers many options that you don’t get with the X++ debugger. It’s sometimes even worth forcing code to run in CIL just to be able to use the VS debugger.

Before actually going to the fancy stuff I want to show, let’s first address a problem that you might run into.

Imagine that you’re debugging a class with an instance variable but you don’t see anything in the list of variables:

EmptyLocals

It’s actually a quite common problem, but I’ve never tried to investigate why it happens, because there is a simple solution: add the variable to the Watch window.

If you see the variable in code, right-click it and choose Add Watch.

AddWatch

You can also type variable names into the Watch window:

TypingToWatch

This not only adds variables to the Watch windows, but they’ll finally appear among Locals as well.

Variables

Leave a Reply

Your email address will not be published.