Recently I came across a requirement for that I need to debug the Batch Jobs but after CIL Generation we cannot debug the logic inside the Batch job. But there is a way to debug the Batch Jobs . Follow the below listed steps to debug the Batch Jobs.
First we need to do or make sure that the following listed settings..
Settings in Microsoft Dynamics AX Server Configuration Utility:
1. Go to Start à Administrative Tools à Microsoft Dynamics AX 2012 Server Configuration
2. On the AOS machine turn debugging on in the server configuration utility by marking following two checkboxes
a. “Enable breakpoints to debug X++ code running on this server”
b. “Enable global breakpoints”.
3. Click yes to restart the AOS.
Settings in Microsoft Dynamics AX Client Configuration Utility:
1. Go to Start Administrative Tools à Microsoft Dynamics AX 2012 Configuration
2. On the client machine turn debugging on in the client configuration utility for the Business Connector.You can do this in the configuration utility by setting the Configuration Target drop down to Business Connector (non-interactive use only).
Set Debugging Mode in AX client:
1. In AX go to Tools > Options > Development tab. Select
“When Breakpoint” in debugging mode option.
Changes in MS Visual Studio:
Do the following settings in .Net application. But these are not mandatory but recommended.
1. Go to Tools à Options.
2. Go to Debugging à General. Ensure the “Enable break point filter” option is selected.
3. Go to symbols in the same window.
4. Click on new folder icon on top right of the window.
Enter the path where all the Microsoft symbols stored, typically the path would be as shown below.
C:Program FilesMicrosoft Dynamics AX60ServerMicrosoftDynamicsAXbinXppIL
Enter the same path in the Cache symbols in the directory. The window would be as shown below.
Click on OK.
Before debugging the Batch Jobs do the following settings in visual studio:
1. Open another instance of Visual Studio,
2.Go to View Menu Bar and click Application Explorer,put the break points in the appropriate classes.
3.Open AX Debugger instance
4.Go to Tools Click on Attach Process.
5. A window will be open with all installed programs. Select AX32serv.exe,AXDebug.exe and Ax32.exe corresponding to your user name as the process to debug and click on Attach.
Note : We should not close this instance of Visual Studio where you did the attach process,just minimize it and keep going on…
6.Add your batch Job in Dynamics AX and wait for visual studio debugger instance.
7. Switch to the visual studio instance and try to debug now.
Start the debugging in Visual studio application then the debugger will automatically switched to batch Job classes where you have kept the break point in another instance which you have minimized.