AX7: Quick and easy debugging

This purpose of this blog is to show how you can get quickly get started with debuggingin AX7, specifically by showing how you can debug an error message issued from AX.

So, let’s begin !

Imagine you are posting a Bank journal and you get the following error message upon posting ‘Currency EUR not allowed for account USMF OPER’

You would like to know the logic behind this error message, but need to trace in the code where it was issued from

AX7: Quick and easy debugging

We will use a classic debugging technique known from AX 2012 to demonstrate how this can be done quickly and easily, by inserting a breakpoint on the Info class to enable the debugger to track down in the code where the error is generated from.

These are the steps 1.Start Visual Studio as ‘Administrator’

AX7: Quick and easy debugging

2.  Go to the Application explorer, go to the ‘Code’ node, select ‘Classes’ and locate the ‘Info’ class

AX7: Quick and easy debugging

On the ‘Info’ class rightclick and select ‘View code’

AX7: Quick and easy debugging

In the window that opens up, select the ‘Add’ method

AX7: Quick and easy debugging

3. Insert your breakpoint on the ‘Add’ method by pressing ‘F9’

AX7: Quick and easy debugging

4. Press ‘Debug’ from the toolbar and select ‘Attach to process’

AX7: Quick and easy debugging

In the ‘Attach to process’ screen mark ‘Show processes from all users’ and then browse to  the process ‘w3wp.exe’

AX7: Quick and easy debugging

Wait for the Symbols to load

AX7: Quick and easy debugging

5. Once the symbols have loaded repeat the application procedure, eg. in this case we will post the journal again to generate the error message

AX7: Quick and easy debugging

And note that almost immediately the debugger starts executing in Visual Studio

AX7: Quick and easy debugging

I copy the call stack into Notepad and here I note especially the highlighted line as this is the line that is triggered just before the call to the Infolog code

AX7: Quick and easy debugging

I can see that the error is triggered on the BankAccountTable, checkCurrency method on line 225 and I stop debugging

AX7: Quick and easy debugging

I go to this code to study the method

I open up the BankAccountTable and similar to as on the ‘Info’ class I select ‘’ and open the method I am interested in

AX7: Quick and easy debugging

Here naturally ‘checkCurrency’

AX7: Quick and easy debugging

And  we can study the code that generated the error message

Naturally, you can use the same technique to insert breakpoints in other places of the code such as on ‘init’, ‘update’ and ‘insert’ methods etc

Happy debugging !

上一篇:Spring MVC详细示例实战教程【转】


下一篇:《网络》:设置三个密码:通过console口连接设备,进入特权模式,登录Telnet