How to: Debug X++ Code on EP Pages
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
X++ code can be used in various resources that are accessed by a page, such as tables, data sets, and classes. You can debug X++ code for elements that are accessed by pages by using the debugger for Microsoft Dynamics AX. You can debug Enterprise Portal code only on the system that is running Internet Information Services (IIS).
Setting Up X++ Debugging for Pages
To set up X++ debugging for pages
Log into the server that is running the AOS.
Open the Microsoft Dynamics AX Server Configuration utility with administrative privileges (Start > Administrative Tools > Microsoft Dynamics AX 2012 Server Configuration). To run the utility with administrative privileges, you must right-click its icon in the Start menu and choose Run as administrator.
Create a new configuration that allows debugging.
Click Manage and then click Create configuration. In the Create Configuration window, name the new configuration, such as "DAX Debugging". Click OK.
On the Application Object Server tab, select Enable breakpoints to debug code X++ code running on this server. Click Apply. If you receive a message about the AOS, indicate that it should be restarted.
Click OK to close the configuration window.
Log in to the server that is running IIS and Enterprise Portal. If the system is remote, you can do this using a Remote Desktop Connection. From the Start menu, click Run. Type the following in the Open box and then click OK:
mstsc /console
This opens a console session in Remote Desktop.
Enable desktop interaction for the World Wide Web Publish Service.
Open the Services window for the system (Start > Administrative Tools > Services).
Right-click the World Wide Web Publishing Service, and then click Properties.
Click the Log On tab.
Select Allow service to interact with desktop.
Click OK to close the properties window.
Open the web.config file located in \Inetpub\wwwroot\wss\VirtualDirectories\<Port>\, where <Port> is the port number of the site where Enterprise Portal is installed. Modify the file by doing the following:
Locate the compilation element, and then set the debug attribute to true. This reduces the chance of the Web session having a time-out error when it is stopped at a breakpoint.
Save the changes.
Reset IIS by typing the iisreset command at the command-line window that has been started with administrative privileges.
Open the Microsoft Dynamics AX Configuration utility with administrative privileges (Start > Administrative Tools > Microsoft Dynamics AX 2012 Configuration). To run the utility with administrative privileges, you must right-click its icon in the Start menu and choose Run as administrator.
Set the Configuration Target drop-down menu to Business Connector (non-interactive use only).
Create a new configuration that allows debugging.
Click Manage and then click Create configuration. In the Create Configuration window, name the new configuration, such as "DAX Debugging". Click OK.
On the Developer tab, select Enable user breakpoints to debug code running in the Business Connector. Click Apply.
Click OK to close the configuration window.
Open the Microsoft Dynamics AX client with administrative privileges. To do this, you must right-click on the icon for Microsoft Dynamics AX and then choose Run as administrator.
Open the Development Workspace.
On the Tools menu, click Options to display the Options window.
Click the Development link. In the Debug area, select When Breakpoint from the Debug mode list box. This enables debugging mode on the client.
Close the Options window.
Debugging X++ code from a Web Page
To debug X++ code from a Web page
Log in to the server that is running Internet Information Services (IIS) and Enterprise Portal. If the system is remote, you can do this using a Remote Desktop Connection. From the Start menu, click Run. Type the following in the Open box and then click OK:
mstsc /console
This opens a console session in Remote Desktop, and is necessary if you want to debug on a remote system.
Important
If you are debugging on a remote system, you must use console mode when connecting. Otherwise, debugging will not work.
Open the Microsoft Dynamics AX client with administrative privileges. To do this, you must right-click on the icon for Microsoft Dynamics AX and then choose Run as administrator.
Be sure that you are logged on as a user who is also the following:
The user who started the session of Microsoft Dynamics AX
The user who will set breakpoints in X++ code
A member of the Microsoft Dynamics AX Debugging Users local group on Windows
Open the Development Workspace.
In the AOT, locate the element that you want to debug. Typically, you will debug data sets, tables, or classes.
Set breakpoints in the X++ code by using the Code Editor.
Open the debugger by clicking Tools, and then clicking Debugger. The Debugger must be open before you can run code that contains breakpoints.
Open the Web page that accesses the element that you want to debug. As the page is rendered, the Debugger should stop at the breakpoints that you set.
Note
If the debugger does not stop at breakpoints, you may have to restart the system that is running Microsoft Dynamics AX. After the restart, try debugging again. Also make sure that you are running the Debugger with administrative privileges.
You can also add the breakpoint statement to your X++ code at the location where you want execution to stop. The X++ debugger should stop when it encounters this keyword.
If you are debugging the list page interaction class for a list page in Enterprise Portal, be sure that the AOS service is running as the same domain user that is being used for the Business Connector Proxy.