SlideShare a Scribd company logo
Fabio Filardi
Dynamics AX Technical Architect
ffilardi@msbsgroup.com
X++ Compiled to .NET CIL


                           Overview


                           Lesson 1: Generating CIL


                           Lesson 2: How Process Works


                           Lesson 3: Debugging CIL Code


                           Lesson 4: Scenarios Not supported


                           Lab: Code Sample
Overview



  Why Is X++ Compiled to CIL?

 The CLR can execute code faster than the AX kernel in the following cases:

     1.   Computationally intensive code that does not do a lot of database access

     2.   Memory intensive code where lots of object are built and stored in
          memory
Overview



  In Microsoft Dynamics AX 2012 X++ batch jobs, service classes, and code
   executed on the AOS calling the RunAs API are compiled into the common
   intermediate language (CIL or simply IL) of the .NET framework.

  You can run your X++ code as CIL by using the method
   Global::runClassMethodIL.

  Using "server" modifier in your methods or setting RunOn Server parameter
   won't make it run as IL necessarily.

  The compilation creates an assembly called Dynamics.Ax.Application.dll which
   is stored on each AOS in the C:Program FilesMicrosoft Dynamics
   AX60ServerMicrosoftDynamicsAXbinXppIL folder.

  The .NET CLR executes the code rather than the AX kernel.
Overview


           RPC        Services




  AOS
                                 •   RunAs()
                                 •   Batch Jobs
                                 •   Services




                 DB
Lesson 1: Generating CIL
This lesson outlines the steps to turn X++ code into generated CIL code



    CIL Generation Steps

        Step                                         Description

        1. Write, save and compile your X++ class.   The X++ source code for your class is automatically
                                                     compiled into p-code when you save your source in
                                                     the AOT.

        2. Compile the p-code into CIL               X++ is compiled into .NET CIL code.
        3. Restart your multiple AOS services.       If your installation has more than one AOS, you
                                                     need to restart every AOS service after the CIL build
                                                     completes. The recycle causes each AOS to load the
                                                     assembly that contains the updated CIL.

        4. Call the class.                           Schedule the batch job that executes your class or
                                                     call the service class.
Lesson 1: Generating CIL
This lesson outlines the steps to turn X++ code into generated CIL code



    CIL Compilation Options

   For step #2 on the previous slide, Compile the p-code into CIL, two options are
   available:

        1. Generate Full CIL
              This option goes through the AOT and generates the CIL for all the modified
              objects that will be used in batch processes or as service classes.

        2. Generate Incremental CIL
              This option causes the CIL to be generated for all objects that have been modified
              since the last time the assembly was generated.
Lesson 1: Generating CIL
This lesson outlines the steps to turn X++ code into generated CIL code



    Generating CIL Code in the Developer Workspace

       Right-click the AOT node of the AOT, and
       navigate to the Add-Ins menu. The last two
       options on the menu will allow you to select the
       desired CIL option:




       You can also use the Build menu:
Lesson 1: Generating CIL
This lesson outlines the steps to turn X++ code into generated CIL code



    Generating CIL Code in the Application Workspace

   As the Administrator navigate to the System administration menu in Microsoft
   Dynamics AX, and then under Periodic, choose ‘Compile into .NET Framework
   CIL’:




   Important: This does a Full CIL generation.
Lesson 1: Generating CIL
This lesson outlines the steps to turn X++ code into generated CIL code



    Restart AOS Instances

   Step #3 in the CIL Generation Process is restart your multiple AOS services.

   After the assembly containing the CIL code has been created, the AOS used for
   the CIL generation has the current version of the assembly. However, other AOS
   have outdated code. To resolve this, the other AOS have to be restarted.
Lesson 2: How Process Works
This lesson explains the process to compile and execute CIL code



    Create and compile

   Objects created in Microsoft Dynamics AX 2012 are stored in the "metadata
   store". In prior versions of Microsoft Dynamics AX, this information was stored in
   the *.AOD files. In Microsoft Dynamics AX 2012, the metadata store has been
   moved into SQL Server.

   X++ compiler examines the object information in the metadata store and
   generates the p-code for that object. When the object is needed, the p-code is
   then executed by the X++ interpreter.

   When the CIL generation is done, the Microsoft Dynamics AX generates an XML
   file that contains a representation of the code based on the metadata for the
   object, and the p-code that exists for that same object. The IL generator will
   generate an assembly and a *.PDB file from the XML.
Lesson 2: How Process Works
This lesson explains the process to compile and execute CIL code



    CIL Generation



               X++


                           PCode




                                                                         .




                                                                   PDB




                                                                   DLL
Lesson 2: How Process Works
This lesson explains the process to compile and execute CIL code



    Netmodules and FileSystem

   If a single class changes, only the module that contains it needs to change while
   all the other types remain untouched.

   Microsoft Dynamics AX 2012 uses an algorithm that is based on the object type
   that is used to determine the ID number value for each netmodule.

   In the file system, the assembly will be represented as one dll file and thousands
   of netmodules files:
Lesson 2: How Process Works
This lesson explains the process to compile and execute CIL code



    Moving Databases between Environments

   The assembly containing the CIL code is stored in the database, and the version
   of the assembly in the database will be restored to the system if the database and
   file system versions are different.

   This is an attention point when updating the development environment with
   another database, like client production/homolog database.
Lesson 3: Debugging CIL Code
This lesson explains how to debug the .NET CIL code created by Dynamics AX



   Requirements for Debugging

   To debug CIL code the AOS must have Debugging enabled via the Server
    configuration utility.

        If debugging on the AOS is not enabled, the source for the X++ code that will be
        displayed in the debugger is not available, and an error is displayed in Visual Studio
        when you attempt to view the X++ source code for an object.

   Visual Studio 2010 (VS) must be installed on the AOS.

        To debug CIL code you have to attach to the AX32Serv.exe process in Visual Studio.
        This is not possible if Visual Studio is not installed on the AOS.
Lesson 3: Debugging CIL Code
This lesson explains how to debug the .NET CIL code created by Dynamics AX



   How to Debug CIL Code

  1.    On the AOS in VS click Tools, and then click Attach to Process.
  2.    In the form that opens mark the checkboxes for Show processes from all
        users and Show processes in all sessions.
  3.    Select AX32Serv.exe.
  4.    Click Attach.
  5.    In VS open the Application Explorer and locate the class or method you want
        to debug. The Application Explorer is simply a read only representation of the
        AOT, you navigate as you would the AOT in Microsoft Dynamics AX.
  6.    Set a breakpoint in the method.
  7.    Execute the batch process or call the service class.

  When the execution arrives at the breakpoint, the Visual Studio debugger
  provides all the functionality that it does for all other .NET languages.
Lesson 3: Debugging CIL Code
This lesson explains how to debug the .NET CIL code created by Dynamics AX



   VS Attach to Process - Screen Example
Lesson 3: Debugging CIL Code
This lesson explains how to debug the .NET CIL code created by Dynamics AX



   VS Debugging AX Class - Screen Example
Lesson 4: Scenarios Not Supported
This lesson explains where we can't use CIL code



    Scenarios not supported and restrictions
    Functions

              There are two X++ functions not supported in CIL: evalbuf and runbuf.

    Incremental CIL Generation Restriction

            Remove a method: a full generation of CIL for the class is necessary to remove
   the method from the existing CIL.

    Compile outcome when a class has one bad method

             The X++ compiler still generates valid p-code for methods that contain no errors,
   even after another method on the same class has been failed to compile. But when a full
   compile of X++ p-code to CIL is performed, the entire compile fails if valid p-code is
   unavailable for any method on any class.

             Until your system has a successful full CIL compile, your system cannot run
   services, SSRS reports, or batch jobs.
Lesson 4: Scenarios Not Supported
This lesson explains where we can't use CIL code



    Methods on Queries and Forms

   Class and tables are types in the X++ language. They can be compiled to CIL.

   The queries and forms in the AOT are not X++ types, and they cannot be
   compiled to CIL.

   This means there are a few minor cases where calls from CIL to X++ p-code can
   cause an exception. The problem is that the CIL session does not have access to
   all the system classes.
Lab: Code Sample
This lab shows two samples to illustrate CIL vs Pcode execution



   In this example we will use a simple condition to check if the active session is a CLR
   Session or not, called direct and by runClassMethodIL.

   1. Create a class with main() and an additional method:




   2. Generate Incremental CIL, and execute the class. Result:
Lab: Code Sample
This lab shows two samples to illustrate CIL vs Pcode execution



   In this example we will use a counter to show that the CIL run completed much faster than
   the interpreted run.

   1. First, create a class (named DemoClassCIL) with main() and 3 additional methods:
Lab: Code Sample
This lab shows two samples to illustrate CIL vs Pcode execution
Lab: Code Sample
This lab shows two examples to illustrate CIL vs Pcode execution



   Generate Incremental IL and execute the class. The result is something like below:




   As seen above, the result in this example was about 40x faster when executed in CIL.
X++ Compiled to .NET CIL




             That s all, thanks.

More Related Content

What's hot (19)

PDF
AWS Cloud Adoption Framework and Workshops
Tom Laszewski
 
PPTX
Domain Driven Design
Ryan Riley
 
PDF
X++ advanced course
Alvin You
 
DOCX
Ax 2012 x++ code best practices
Saboor Ahmed
 
PPTX
Design pattern - Facade Pattern
Mudasir Qazi
 
PDF
Developer's guide to customization
Ahmed Farag
 
PPT
Oracle Fusion Development, May 2009
Jaime Cid
 
PPTX
AWS Lambda
Andrew Dixon
 
PPTX
Azure IAAS architecture for beginners and developers - Part 1
Malleswar Reddy
 
PPTX
Facade pattern presentation(.pptx)
VishalChavan83
 
DOCX
Create rest webservice for oracle public api using java class via jdeveloper
shravan kumar chelika
 
PPTX
Journey to Cloud: Fast Track to Azure
Fausto Pasqualetti
 
PDF
Deconstructing Monoliths with Domain Driven Design
VMware Tanzu
 
PPTX
Teams Day Online V - Information Barriers - Communication Compliance and Micr...
Albert Hoitingh
 
PPSX
Introduction to .net framework
Arun Prasad
 
PDF
The Kubernetes WebLogic revival (part 1)
Simon Haslam
 
PDF
Dynamics Ax Retail Installation Vijay Sharma
Vijay Sharma
 
PPTX
AWS Storage Gateway
zekeLabs Technologies
 
AWS Cloud Adoption Framework and Workshops
Tom Laszewski
 
Domain Driven Design
Ryan Riley
 
X++ advanced course
Alvin You
 
Ax 2012 x++ code best practices
Saboor Ahmed
 
Design pattern - Facade Pattern
Mudasir Qazi
 
Developer's guide to customization
Ahmed Farag
 
Oracle Fusion Development, May 2009
Jaime Cid
 
AWS Lambda
Andrew Dixon
 
Azure IAAS architecture for beginners and developers - Part 1
Malleswar Reddy
 
Facade pattern presentation(.pptx)
VishalChavan83
 
Create rest webservice for oracle public api using java class via jdeveloper
shravan kumar chelika
 
Journey to Cloud: Fast Track to Azure
Fausto Pasqualetti
 
Deconstructing Monoliths with Domain Driven Design
VMware Tanzu
 
Teams Day Online V - Information Barriers - Communication Compliance and Micr...
Albert Hoitingh
 
Introduction to .net framework
Arun Prasad
 
The Kubernetes WebLogic revival (part 1)
Simon Haslam
 
Dynamics Ax Retail Installation Vijay Sharma
Vijay Sharma
 
AWS Storage Gateway
zekeLabs Technologies
 

Viewers also liked (13)

PPTX
Microsoft Dynamics AX 2012 - Development Introduction Training - Part 2/3
Fabio Filardi
 
PPTX
Azure overview
Fabio Filardi
 
PDF
AX 2012 R3 Installation Guide
Biswanath Dey
 
PPTX
Microsoft dynamics ax2012 : forms and tables methods call sequences, How To?
Mohamed Amine HAMDAOUI
 
PDF
Dynamics ax performance tuning
OutsourceAX
 
PPTX
Ax 2012 enterprise portal development
Moutasem Al-awa
 
PPTX
AX 2012: All About Lookups!
MAnasKhan
 
PPTX
Closed Loop Marketing (CLM)
Sai Kumar
 
DOCX
CRM AT A GLANCE
Charu Sharma
 
PPTX
Closed-loop Marketing Analytics
David Delong
 
PPTX
Microsft Dynamics AX Introduction
Mohamed Samy
 
PPTX
Dynamic AX : Application Integration Framework
Saboor Ahmed
 
DOCX
Developing ssrs-reports-for-dynamics-ax
Nicc Ngo
 
Microsoft Dynamics AX 2012 - Development Introduction Training - Part 2/3
Fabio Filardi
 
Azure overview
Fabio Filardi
 
AX 2012 R3 Installation Guide
Biswanath Dey
 
Microsoft dynamics ax2012 : forms and tables methods call sequences, How To?
Mohamed Amine HAMDAOUI
 
Dynamics ax performance tuning
OutsourceAX
 
Ax 2012 enterprise portal development
Moutasem Al-awa
 
AX 2012: All About Lookups!
MAnasKhan
 
Closed Loop Marketing (CLM)
Sai Kumar
 
CRM AT A GLANCE
Charu Sharma
 
Closed-loop Marketing Analytics
David Delong
 
Microsft Dynamics AX Introduction
Mohamed Samy
 
Dynamic AX : Application Integration Framework
Saboor Ahmed
 
Developing ssrs-reports-for-dynamics-ax
Nicc Ngo
 
Ad

Similar to Microsoft Dynamics AX 2012 - X++ Compiled to CIL (20)

PDF
T2
lksoo
 
PDF
Dbva dotnet programmer_guide_chapter8
Shakeel Mujahid
 
PDF
tybsc it asp.net full unit 1,2,3,4,5,6 notes
WE-IT TUTORIALS
 
PPTX
01. introduction to-programming
Stoian Kirov
 
PPTX
C++Basics2022.pptx
Danielle780357
 
PPTX
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
PPTX
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 
PPTX
C++ helps you to format the I/O operations like determining the number of dig...
bhargavi804095
 
PPTX
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
bhargavi804095
 
PPT
01 Introduction to programming
maznabili
 
DOC
Introduction-to-C-Part-1 (1).doc
MayurWagh46
 
PPT
C Sharp Jn
jahanullah
 
PPT
C Sharp Jn
guest58c84c
 
PDF
Introduction-to-C-Part-1.pdf
AnassElHousni
 
PPT
ASP.NET Session 1
Sisir Ghosh
 
PPT
Session gwjanhdienjsgek2nwgei2792jej 1.ppt
r86308281
 
PDF
Micro Processor & Micro Controller Practical Notes_Electrical Engineering GTU...
Parth Gajjar
 
PPT
Introduction to Programming Lesson 01
A-Tech and Software Development
 
PDF
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
Databricks
 
PPT
ASP.NET 01 - Introduction
Randy Connolly
 
T2
lksoo
 
Dbva dotnet programmer_guide_chapter8
Shakeel Mujahid
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
WE-IT TUTORIALS
 
01. introduction to-programming
Stoian Kirov
 
C++Basics2022.pptx
Danielle780357
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 
C++ helps you to format the I/O operations like determining the number of dig...
bhargavi804095
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
bhargavi804095
 
01 Introduction to programming
maznabili
 
Introduction-to-C-Part-1 (1).doc
MayurWagh46
 
C Sharp Jn
jahanullah
 
C Sharp Jn
guest58c84c
 
Introduction-to-C-Part-1.pdf
AnassElHousni
 
ASP.NET Session 1
Sisir Ghosh
 
Session gwjanhdienjsgek2nwgei2792jej 1.ppt
r86308281
 
Micro Processor & Micro Controller Practical Notes_Electrical Engineering GTU...
Parth Gajjar
 
Introduction to Programming Lesson 01
A-Tech and Software Development
 
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
Databricks
 
ASP.NET 01 - Introduction
Randy Connolly
 
Ad

Recently uploaded (20)

PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 

Microsoft Dynamics AX 2012 - X++ Compiled to CIL

  • 2. X++ Compiled to .NET CIL Overview Lesson 1: Generating CIL Lesson 2: How Process Works Lesson 3: Debugging CIL Code Lesson 4: Scenarios Not supported Lab: Code Sample
  • 3. Overview  Why Is X++ Compiled to CIL? The CLR can execute code faster than the AX kernel in the following cases: 1. Computationally intensive code that does not do a lot of database access 2. Memory intensive code where lots of object are built and stored in memory
  • 4. Overview  In Microsoft Dynamics AX 2012 X++ batch jobs, service classes, and code executed on the AOS calling the RunAs API are compiled into the common intermediate language (CIL or simply IL) of the .NET framework.  You can run your X++ code as CIL by using the method Global::runClassMethodIL.  Using "server" modifier in your methods or setting RunOn Server parameter won't make it run as IL necessarily.  The compilation creates an assembly called Dynamics.Ax.Application.dll which is stored on each AOS in the C:Program FilesMicrosoft Dynamics AX60ServerMicrosoftDynamicsAXbinXppIL folder.  The .NET CLR executes the code rather than the AX kernel.
  • 5. Overview RPC Services AOS • RunAs() • Batch Jobs • Services DB
  • 6. Lesson 1: Generating CIL This lesson outlines the steps to turn X++ code into generated CIL code  CIL Generation Steps Step Description 1. Write, save and compile your X++ class. The X++ source code for your class is automatically compiled into p-code when you save your source in the AOT. 2. Compile the p-code into CIL X++ is compiled into .NET CIL code. 3. Restart your multiple AOS services. If your installation has more than one AOS, you need to restart every AOS service after the CIL build completes. The recycle causes each AOS to load the assembly that contains the updated CIL. 4. Call the class. Schedule the batch job that executes your class or call the service class.
  • 7. Lesson 1: Generating CIL This lesson outlines the steps to turn X++ code into generated CIL code  CIL Compilation Options For step #2 on the previous slide, Compile the p-code into CIL, two options are available: 1. Generate Full CIL This option goes through the AOT and generates the CIL for all the modified objects that will be used in batch processes or as service classes. 2. Generate Incremental CIL This option causes the CIL to be generated for all objects that have been modified since the last time the assembly was generated.
  • 8. Lesson 1: Generating CIL This lesson outlines the steps to turn X++ code into generated CIL code  Generating CIL Code in the Developer Workspace Right-click the AOT node of the AOT, and navigate to the Add-Ins menu. The last two options on the menu will allow you to select the desired CIL option: You can also use the Build menu:
  • 9. Lesson 1: Generating CIL This lesson outlines the steps to turn X++ code into generated CIL code  Generating CIL Code in the Application Workspace As the Administrator navigate to the System administration menu in Microsoft Dynamics AX, and then under Periodic, choose ‘Compile into .NET Framework CIL’: Important: This does a Full CIL generation.
  • 10. Lesson 1: Generating CIL This lesson outlines the steps to turn X++ code into generated CIL code  Restart AOS Instances Step #3 in the CIL Generation Process is restart your multiple AOS services. After the assembly containing the CIL code has been created, the AOS used for the CIL generation has the current version of the assembly. However, other AOS have outdated code. To resolve this, the other AOS have to be restarted.
  • 11. Lesson 2: How Process Works This lesson explains the process to compile and execute CIL code  Create and compile Objects created in Microsoft Dynamics AX 2012 are stored in the "metadata store". In prior versions of Microsoft Dynamics AX, this information was stored in the *.AOD files. In Microsoft Dynamics AX 2012, the metadata store has been moved into SQL Server. X++ compiler examines the object information in the metadata store and generates the p-code for that object. When the object is needed, the p-code is then executed by the X++ interpreter. When the CIL generation is done, the Microsoft Dynamics AX generates an XML file that contains a representation of the code based on the metadata for the object, and the p-code that exists for that same object. The IL generator will generate an assembly and a *.PDB file from the XML.
  • 12. Lesson 2: How Process Works This lesson explains the process to compile and execute CIL code  CIL Generation X++ PCode . PDB DLL
  • 13. Lesson 2: How Process Works This lesson explains the process to compile and execute CIL code  Netmodules and FileSystem If a single class changes, only the module that contains it needs to change while all the other types remain untouched. Microsoft Dynamics AX 2012 uses an algorithm that is based on the object type that is used to determine the ID number value for each netmodule. In the file system, the assembly will be represented as one dll file and thousands of netmodules files:
  • 14. Lesson 2: How Process Works This lesson explains the process to compile and execute CIL code  Moving Databases between Environments The assembly containing the CIL code is stored in the database, and the version of the assembly in the database will be restored to the system if the database and file system versions are different. This is an attention point when updating the development environment with another database, like client production/homolog database.
  • 15. Lesson 3: Debugging CIL Code This lesson explains how to debug the .NET CIL code created by Dynamics AX  Requirements for Debugging  To debug CIL code the AOS must have Debugging enabled via the Server configuration utility. If debugging on the AOS is not enabled, the source for the X++ code that will be displayed in the debugger is not available, and an error is displayed in Visual Studio when you attempt to view the X++ source code for an object.  Visual Studio 2010 (VS) must be installed on the AOS. To debug CIL code you have to attach to the AX32Serv.exe process in Visual Studio. This is not possible if Visual Studio is not installed on the AOS.
  • 16. Lesson 3: Debugging CIL Code This lesson explains how to debug the .NET CIL code created by Dynamics AX  How to Debug CIL Code 1. On the AOS in VS click Tools, and then click Attach to Process. 2. In the form that opens mark the checkboxes for Show processes from all users and Show processes in all sessions. 3. Select AX32Serv.exe. 4. Click Attach. 5. In VS open the Application Explorer and locate the class or method you want to debug. The Application Explorer is simply a read only representation of the AOT, you navigate as you would the AOT in Microsoft Dynamics AX. 6. Set a breakpoint in the method. 7. Execute the batch process or call the service class. When the execution arrives at the breakpoint, the Visual Studio debugger provides all the functionality that it does for all other .NET languages.
  • 17. Lesson 3: Debugging CIL Code This lesson explains how to debug the .NET CIL code created by Dynamics AX  VS Attach to Process - Screen Example
  • 18. Lesson 3: Debugging CIL Code This lesson explains how to debug the .NET CIL code created by Dynamics AX  VS Debugging AX Class - Screen Example
  • 19. Lesson 4: Scenarios Not Supported This lesson explains where we can't use CIL code  Scenarios not supported and restrictions  Functions There are two X++ functions not supported in CIL: evalbuf and runbuf.  Incremental CIL Generation Restriction Remove a method: a full generation of CIL for the class is necessary to remove the method from the existing CIL.  Compile outcome when a class has one bad method The X++ compiler still generates valid p-code for methods that contain no errors, even after another method on the same class has been failed to compile. But when a full compile of X++ p-code to CIL is performed, the entire compile fails if valid p-code is unavailable for any method on any class. Until your system has a successful full CIL compile, your system cannot run services, SSRS reports, or batch jobs.
  • 20. Lesson 4: Scenarios Not Supported This lesson explains where we can't use CIL code  Methods on Queries and Forms Class and tables are types in the X++ language. They can be compiled to CIL. The queries and forms in the AOT are not X++ types, and they cannot be compiled to CIL. This means there are a few minor cases where calls from CIL to X++ p-code can cause an exception. The problem is that the CIL session does not have access to all the system classes.
  • 21. Lab: Code Sample This lab shows two samples to illustrate CIL vs Pcode execution In this example we will use a simple condition to check if the active session is a CLR Session or not, called direct and by runClassMethodIL. 1. Create a class with main() and an additional method: 2. Generate Incremental CIL, and execute the class. Result:
  • 22. Lab: Code Sample This lab shows two samples to illustrate CIL vs Pcode execution In this example we will use a counter to show that the CIL run completed much faster than the interpreted run. 1. First, create a class (named DemoClassCIL) with main() and 3 additional methods:
  • 23. Lab: Code Sample This lab shows two samples to illustrate CIL vs Pcode execution
  • 24. Lab: Code Sample This lab shows two examples to illustrate CIL vs Pcode execution Generate Incremental IL and execute the class. The result is something like below: As seen above, the result in this example was about 40x faster when executed in CIL.
  • 25. X++ Compiled to .NET CIL That s all, thanks.