Debugger

Debugger is one of the most important tools when programming in AX. This appendix is written as a
quick guide on how to use the debugger.
The debugger is installed as a separate application and can be opened directly
from Windows or you can open it from AX. There are two ways of opening the
debugger in AX. You can open it before you start executing whatever you would
like to debug by pressing the Microsoft Dynamics AX button (Alt + M) and then
navigate to Tools | Development Tools | Debugger.
The debugger is also started automatically when the code execution hits a breakpoint.
If you are trying to debug code that is executed through the .NET Business Connector
there are certain steps you have to follow.


how-to-debug-enterprise-portal-code-in-dynamics-ax-2009.aspx
If the code you would like to debug runs on the server you will need to enable
server-side debugging in the AX 2009 Server Configuration Tool.
To actually debug a piece of code simply press F9 to add a breakpoint in the code.
Try to do this somewhere in the Job Collection_Set that we created in Chapter 2,
X++ language. You can also modify the code and write the statement breakpoint;
to set a breakpoint. This can be especially helpful when debugging form controls.

Make sure that the debugger is installed on your client computer and that
debugging is enabled for your user by navigating to the Options form
(Microsoft Dynamics AX button (Alt+M), followed by Tools | Options).
Navigate to the Development tab and make sure that the Debug Mode
field is set to When Breakpoint.

Make sure that the debugger is installed on your client computer and that
debugging is enabled for your user by navigating to the Options form
(Microsoft Dynamics AX button (Alt+M), followed by Tools | Options).
Navigate to the Development tab and make sure that the Debug Mode
field is set to When Breakpoint.

          The following is the description of the screen in the previous screenshot:
1. Code window: This window displays the code that is being executed. The
red bullet to the left of the line numbering indicates a breakpoint. The yellow
arrow on top of the breakpoint indicates the line that is about to be executed.
2. Variable window: The variables that are in the selected context are shown
here. The variable window is divided into the following three tabs:
 Local: Shows the variables in the current execution scope
 Globals: Shows variables from the objects that are
always created when AX runs (InfoLog, VersionControl,
Classfactory, and Appl)
 

3. Call Stack window: This window displays the methods that have been
executed in order to get to the current code. Therefore, when method A calls
method B which in turn calls method C, they will be listed in this window
where method C is on the top and method A is at the bottom. You can also
double-click on a path in the call stack to see that method’s code in the
code window.
4. Watch window: In this window you can look for certain variables regardless
of their context. If they are in the current context then a value will be shown
if they have any. You can mark a variable in the Code window and drag it to
the Watch window to add it to the watch list.
5. Breakpoints window: This window shows all the breakpoints you have set
in AX. You can also set new breakpoints and remove breakpoints directly in
the debugger.
6. Output window: This window will display different kinds of output
as follows:

 Debug: You can write statements in the code, such as
the following and have them traced in this window:
Debug::printDebug(“Test something”);

 Infolog: All messages sent to the infolog

Database, Method, Client/Server, ActiveX: Any traces
generated by these if their flags have been switched on in the
Options form (Microsoft Dynamics AX button (Alt + M) and
navigate to Tools | Options)
7. Info bar: This part of the debugger shows the following information related
to the current session:
 User: The user executing the current session
 Session: The identifier of the current server session
Company: The three lettered ID of the current company
account
 TTS: The transaction level for the current session
 Ln, Col: Line number and Column of the cursor in the
code window

The following are the main operations of the debugger (see a full list of shortcuts in
the List of all standard shortcut keys in AX link in Appendix A, Links):
• Step over – F10: Executes the current line without debugging methods called
by the statement if any.
• Step into – F11: Steps into the method called by the current line. If more than
one method is called the innermost will have the top priority, then the first
one to the left-hand side of the line, and then rightmost.
• Step out – Shift + F11: Steps out of the current method and moves back to the
caller method (previous method in the stack).
• Go back: Drag the yellow arrow to a previous line of code in the current
method to go back. Remember that the variables will not automatically be
reset to the state they had when that line executed for the first time.
• Run – F5: Continue the execution and jump to the next breakpoint if any.
• Run to cursor – Ctrl + F10: Continue to execute and break at the line where
the cursor is in the code window.
• Stop debugging – Shift + F5: Stop executing the code. None of the lines after
the current execution position will be executed.

 
  • Trackback are closed
  • Comments (12)
    • Taha Durgut
    • Eylül 14th, 2010 5:47pm

    Merhaba fatif bey debugger konusunda bir sorunum var
    AOT menüsünden > clases> saleslinetype>initforminventtable> kod editör sayfasında breakpoint oluşturuyorum daha sonra AR> menüsünden sales order detail den yeni bir sales order oluşturuyorum ok deyip çıktıktan sonra item numarasını giriyorum buraya kadar herşey yolunda fakat daha sonra toolbardan tools > devolpment tools > debugger yaptığımda break point oluşturduğum halde debugger yapılmıyor sizce sorun nerede ve bu sorunu nasıl çözebilirim ?

    Saygılarımla.

    • Debug yapmak için debugerı aktif etmiş olmanız lazım sanırım bunları yapmışsınızdır.
      Clasta breakpointi koyduğunuz yere kodun girip girmediğinden emin olun. Emin olamiyorsanız ilk satıra koyup kodu takip edebilirsiniz.
      Bazı form metodlarında debug çalıştıramazsınız.örneğim medifiad click gibi. Bu yüzden bu metodlara kod yazmak yerine formun motodlarına metod yazıp orayı çağırırsanız debug edebilirsiniz.

        • Taha Durgut
        • Eylül 15th, 2010 11:40pm

        Merhaba Fatih bey uyarılarınız doğrultusunda debuggerı aktif ettim fakat yine olumlu bir sonuç alamadım aşağıda verdiğim url den debugger yapılması istenen bilgiler mevcuttur zamanınız imkan verdiği ölçüde debugger yapmayı birde siz deneyebilirseniz sorunun ortaya çıkacağını düşünüyorum
        Saygılarımla İyi Çalışmalar.

        http://www.hizliupload.com/img/ekranabnb.png

        • Merhaba
          Microsoft Dynamics AX Configuration Utility de Developer sekmesinde Enable User Breekponts to code running in the Business connector ve Enable User Breekponts to code running in the Business connector client’ı işaretlemeniz gerekiyor.

          Bunlardan sonra serveri restart edip tekrar deneyin.

          Selamlar.

            • Taha Durgut
            • Eylül 17th, 2010 6:13pm

            Merhaba;
            Yardımlarınız için çok teşekkür ederim

            Saygılarımla..

  1. I stumbled upon this post from technoratic, good blog, keep it up.

  2. Should i repost this on my blog? I am going to set you a back-link. Let me know, thank you!

    • Sinan Yürekli
    • Mayıs 9th, 2014 12:13pm

    Merhabalar.Bu siteye yazdıgım için tekrar yazmak istemedim.Bir form içinde DocuView butonu için kısayol yapmak istiyoruz.Örneğin Ctrl + j gibi.. bu konuda yardımcı olabilirmisiniz.Macrolar için ResAppl,task,Keypressed macrolarına baktık lakin çıkaramadık.
    http://dynamicsuser.net/forums/t/75343.aspx

    • Merhaba task metodunu kullanmalısınız. Basıt bir örnek şöyle:
      public int task(int _taskId)
      {
      int ret;

      ret = super(_taskId);
      if(_taskId == 2827)//2827 => TAB
      element.close();

      return ret;
      }

    • Sinan Yürekli
    • Mayıs 9th, 2014 12:13pm

    Merhabalar.Bu siteye yazdıgım için tekrar yazmak istemedim.Ax 2009 için Bir form içinde DocuView butonu için kısayol yapmak istiyoruz.Örneğin Ctrl + j gibi.. bu konuda yardımcı olabilirmisiniz.Macrolar için ResAppl,task,Keypressed macrolarına baktık lakin çıkaramadık.

    • Merhaba task metodunu kullanmalısınız. Basıt bir örnek şöyle:

      public int task(int _taskId)
      {
      int ret;

      ret = super(_taskId);
      if(_taskId == 2827)//2827 => TAB
      element.close();

      return ret;
      }

Comment are closed.

Türkiye'nin en doğru, dolu dolu ve hatasız anlatımları ile teknik yazılarına, makalelerine, video'larına, seminerlerine, forum sayfasına ve sektörün önde gelenlerine ulaşabileceğiniz teknik topluluğu, MSHOWTO