From July 9th till 13th we will be at #MSInspire. See you there!

Debugging AIF Services in Dynamics AX 2012

Debugging AIF Services in Dynamics AX 2012
15 Dec 2014

Hi Guys,

In this post we’ll take a closer look at debugging AIF services in Dynamics AX 2012. Debugging is a critical part of the development process as it helps you identify any defects in your code, so you can fix them. The MorphX integrated development environment (IDE) provided by Dynamics AX provides excellent support for debugging X++ code, and you can use it to inspect X++ code that is part of your Dynamics AX Jobs, Reports, Forms, Tables, etc.

But when it comes to debugging AIF services in Dynamics AX 2012, you can’t rely on the in-environment debugging capability of the MorphX IDE alone. Granted that you can use the Jobs feature in to help you debug the service classes while staying within AX, but debugging a service call that is triggered from outside by some client consuming the AIF service, can’t be done while staying within MorphX. For that you will need to utilize the debugging capabilities provided by Visual Studio. Here’s how you can do that.

Debugging AIF Services in Dynamics AX 2012

  • First, you’ll need Visual Studio installed on the same machine where AOS reside. You’ll also need Dynamics AX Application Explorer component installed as well. The AX Application Explorer is a Visual Studio add-on that is used browse the AX AOT (Application Objects Tree) within Visual Studio. You can install it from the Microsoft Dynamics AX CD by choosing Developer Tools > Visual Studio Tools.
  • Next, open Visual Studio and in the Application Explorer pane expand the AOT (Application Objects Tree) and navigate to the AIF Service. Expand the methods given here and open the method that you want to debug. Add a breakpoint to the code line that you’re interested in.
  • Since AIF Services code is compiled into CIL (Common Intermediate Language) and run on the server, to debug it you’ll need to attach the debugger to the server (Ax32Serv.exe) process. For this, select Debug menu > Attach to Process. Then select ‘Ax32Serv.exe’ and press ‘Attach’. Wait for until the code is attached to the process and all the relevant files and debugging symbols have been loaded into the memory.
  • Now, make the service call from the client application and the control will eventually stop over the break point.

There are a few things that should keep in mind though while debugging AIF Services in Dynamics AX 2012. First off, if you want to step into another method or methods during the debugging process, you will need to have them pre-loaded (opened) in your Visual Studio IDE before you can actually attach the process. Also, you can’t alter the code while debugging in Visual Studio. You will have to make the changes in X++ code and compile it, in order to make it available for further debugging, if required.

About Folio3 Dynamics Services

FDS (Folio3 Dynamics Services) is a dedicated division of Folio3 that specializes in Microsoft Dynamics AX, Dynamics CRM, Dynamics NAV and Dynamics GP based development, customization and integration services. Our main focus is on Enterprise Mobility. We firmly believe that opening up Microsoft Dynamics AX and other products to iOS Android, Windows 8 and Windows Phone users will have a huge impact on organizational agility and productivity.

Share

Noc Folio3