AIF / Services Debugging in Dynamics AX


Today, I will tell you all about AIF debugging in AX 2009 and AX 2012

Microsoft Dynamics AX 2009

Debugging of the AIF code in AX 2009 is not possible by default. In case you really need it, here are the steps you should take. To enable debugging for the Inbound processing:

1. Open AOT in development workspace and find the AIFInboundProcessingService class.

2. Select the runAsWrpper method and make the following adjustments:

    • comment this code:

// runas(axaptaUserId,

// classnum(AifInboundProcessingService),

// staticmethodstr(AifInboundProcessingService, processAsUser),

// messageIdContainer);

    • add instead the next line:


    • change the method modifier to public instead of private:

public static void runAsWrapper(AifWindowsUser                                                  runAsUserId,

container                                                   messageIdContainer)

The same modifications can be done for the Outbound processing in the runAsWrapper method of the AIFOutboundProcessingService class.

Keep in mind that the source code changes should not be performed in a production system. Doing so might affect running batch processes in AIF.

Microsoft Dynamics AX 2012

Services in AX 2012 run as the IL code and the Dynamics AX debugger is useless, as setting a breakpoint in your document class will be ignored. Therefore, you need Visual Studio.

To debug AIF in AX 2012 take the following steps:

    • Go to the server environment and open AX Server Configuration Utility: Start > Administrative Tools > Microsoft Dynamics AX 2012 Server Configuration.
    • Make sure that the configuration is correct and that the Enable breakpoints to debug X++ code running on this server and Enable global check-boxes are marked.
    • Save your changes by clicking Apply. If you are prompted to restart AOS, click Yes.
    • Open AX Configuration Utility: Start > Administrative Tools > Microsoft Dynamics AX 2012 Configuration. Set Configuration target to Business Connector (non-interactive use only).
    • Now, the configuration that enables debugging needs to be created. Click Manage > Create configuration. Name the configuration in the dialog and click OK.
    • Open the tab page Developer to mark the Enable user breakpoints to debug code running in the Business Connector and Enable global breakpoints to debug code running in the Business Connector or client check-boxes. Apply your changes and close the configuration window.
    • Open Visual Studio and choose View > Application Explorer from the main menu of IDE. If the AOS Disconnected message appears in Application Explorer, IDE should be configured for opening with a specific AX client configuration. As soon as you get connected, find the required code in AOT of the Application Explorer pane and set the breakpoint on the X++ source code.
    • To attach IDE to the AOS process, choose Attach to process in the Debug menu. Make sure that the check-boxes Show processes from all users and Show processes from all sessions are marked.
    • If you have many AOS services because of multiple AOS configurations, ensure that you choose the right one, as they differ only by their ID. Use Task manager for this check: open the process properties and from the AOS path get the AOS name.
    • When you found the process the IDE should be attached to, select it in the Attach to process window.
    • In a new instance of Visual Studio open the code that is called by service and run it. The debugger will automatically switch to the instance that has the breakpoints set by you.

Please note that you have to generate the incremental CIL to regenerate *.xpp files before debugging if you have previously made any changes to the X++ code.

Stay tuned for more on debugging Dynamics AX 2009 and 2012. See you next week!