program execution at that point and enter the debug mode.
When the logic flow of the code in a user's session reaches a breakpoint set by
the same user, the debug session begins and the debugger is automatically
started.
To set a breakpoint:
1. Rest the cursor within the X++ code in the editor where you want to
insert the breakpoint.
2. Click the Breakpoint button in the toolbar or press F9.
3. Click in the gray area to the left of the line of code.
The line of code is highlighted in dark red to indicate that a breakpoint is
enabled. A disabled breakpoint is indicated with a red border only. Disabled
breakpoints will not cause program execution to stop, but are useful when a
specific location needs to be remembered, perhaps to enable the breakpoint at a
later point.
Breakpoints can also be set by inserting the keyword Breakpoint into the code.
This should be used with caution, because it will mean that all users will enter the
debugger when the code reaches this point.
All these methods of settings breakpoints are shown in the following figure:
To turn debugging off, you can visit Tools > Options, and select the Developertab. In the Debug field, select None. When you set a breakpoint in code, this field
will automatically be set back to When Breakpoint.
Breakpoints are only recognized on the tiers (client or server) that have been
configured to recognize them. Code running on the client tier will always stop at
a breakpoint in a user's session, when the user has debugging turned on. Code
running on the server tier will only stop at a breakpoint when the AOS has
specifically been configured to enable breakpoints. This is a setting on the
Microsoft Dynamics AX Server Configuration Utility.
The Debugger can display up to six information windows. The windows display
detailed information about the current state of the executing code while you are
debugging. The information windows available are as follows:
Window | Description |
Code | Displays the X++ code currently being debugged. The red dot indicates where the breakpoint is inserted. The yellow arrow indicates the line that is being executed. The arrow can be dragged to a different line of code so that code is either re-executed or skipped. |
Variables | Displays the value of the variables. Modified variables appear in different colors to indicate change. Users can alter the value of variables in the debugger to see how the program would run under different conditions. |
Call Stack | Indicates which method is currently being debugged. Double-clicking a method further down the stack will take the Code window to that method. |
Watch | Contains a user-defined range of variables. The variables can be dragged and dropped from the Variables window or the Code window. |
Breakpoints | Displays the list of currently defined breakpoints with their enabled status and line number. |
Output | Displays separate views of text written to the window from X++ code and kernel code. These views organize information sent to the Output window. |
HINT: The Microsoft Dynamics AX Debugger Help Guide can be accessed
directly by pressing F1 in the debugger. This guide lists keyboard shortcuts that
make it easier and faster to use the debugger.
Use the toolbar located above the Output window to navigate through the code
and perform other actions.
Moving the pointer over these buttons reveals the button's function and a
keyboard shortcut.
The more generally used buttons are described in the following table, together
with the keyboard shortcut:
Button | Keystroke | Description |
Go | F5 | Continues the execution. |
Stop Debugging | Shift + F5 | Terminates the execution at the current line. |
Insert/Remove Breakpoint | F9 | Inserts or clears a breakpoint. |
Enable/Disable Breakpoint | Ctrl + F9 | Enables or disables a breakpoint. |
Remove all breakpoints | Ctrl + Shift + F9 | Clears all breakpoints. |
Step Over | F10 | Steps to the next line of code in the current method. |
Step Into | F11 | Steps into the current line if it contains a method call. |
Step Out | Shift + F11 | Steps out of the current method. |
Run to Cursor | Ctrl + F8 | Continues the execution until reaching the location of the cursor in the Sourcewindow. |
By default, for performance reasons, debugging in code that is executed on the
AOS is disabled. During development it is often required to debug this code. The
following procedure will enable code run on the AOS to be debugged.
1. Close the Microsoft Dynamics AX client
2. Click Start > Administrative Tools > Microsoft Dynamics AX
2012 Server Configuration3. Click Manage > Create Configuration4. In the Configuration Name, enter a name, for example AOS_Debug.
5. Click OK6. Check the box Enable breakpoints to debug X++ code running on
this Server
7. Click Apply8. Click Yes to restart the AOS service. This may take one or two
minutes.
9. Click OK to close the Server Configuration Utility.
10. Restart the Microsoft Dynamics AX client.
Regards,
Hossein Karimi
No comments:
Post a Comment