Saturday, July 14, 2018

Visual Studio Debugging Experience for X++

With a tight integration between X++ and Visual Studio, an integrated debugging
experience is essential for developers. It is possible to use the Visual Studio
debugger to debug managed code that is called from X++. The opposite is also
true. X++ code that is called from managed code can be debugged using the
Microsoft Dynamics AX debugger.


Debugging Managed Code Called from X++

Perform the following procedure to debug managed code called from X++ code.
The procedure continues with the example of the
MyPreEventHandler managed
code, on the
SalesFormLetter.run() event:

1. Create a job in Microsoft Dynamics AX that executes
SalesFormLetter.run().

2. In Visual Studio, put a breakpoint on a line of code within the
preRun method of the MyPreEventHandler class.

3. Select
Debug and then Attach to Process.

4. From the
Available Processes field, select the Microsoft Dynamics
AX client process (
Ax32.exe) and click Attach. The client process is
selected since the code being debugged runs on the client.


5. In Microsoft Dynamics AX, run the job.


6. The Visual Studio debugger will appear, waiting at the breakpoint.


Debugging X++ Called from Managed Code

Perform the following procedure to debug X++ code called from managed code.

1. Create managed code in Visual Studio that calls a method on a
Microsoft Dynamics AX proxy (table or class).


2. On the Visual Studio project's properties, set
Debug Target toClient and Startup Element to the AOT element that contains the
X++ code you wish to debug. The format of this property should be
"AOT Node\Element Name". For example,
Classes\SalesLineType.
Acceptable element types are job, menu item, class and form.
 

3. In that startup element in Microsoft Dynamics AX, place a
breakpoint in the X++ code you wish to debug.


4. Press F5 in Visual Studio to debug the managed code.


5. When code execution reaches a breakpoint in X++ code, context will
switch to the Microsoft Dynamics AX debugger.
 

Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...