Debugging AIF Service in AX2012

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.

4 comments:

  1. Hi Vishal,

    In Dynamics AX 2012-CU8, we have the standard functionality to import the Credit card Transaction using Csv/TXT file (Path- Travel and expense- Periodic- Credit Card- Credit card import from folder).

    I am trying to import the file and file is importing successfully. But to modify some of the fields information, I need to modify the DLL for the same. I mean we have .NET business assembly which transform csv to XML and it is a DLL file. We are using NETTcp adaptor.

    I have deployed the DLL on client using visual studio (by setting deployment target as client) and the debugger is not hitting in .NET code during this process and I have attached the AX 32.exe(not AX32Serv.exe as I am not able to see AX32Serv.exe in my process) to the process as well.

    My Visual studio version is 2013. And my Visual studio and AOS are on two different machine. I have windows 8 at my client machine and Windows server 2012 on sever machine.

    Could you or anyone please suggest me If I am missing anything ?

    ReplyDelete
  2. I just added this feed to my bookmarks. I enjoy reading your posts. Thank you!

    http://spectoittraining.com/microsoft-dynamics-ax-trade-and-logistics-online-training/

    ReplyDelete
  3. Thanks again for the article post.Really thank you! Fantastic.
    best online java corse
    java online classes

    ReplyDelete

Powered by Blogger.