SlideShare une entreprise Scribd logo
1  sur  25
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.

Contenu connexe

Tendances

Dynamics Ax Retail Installation Vijay Sharma
Dynamics Ax Retail Installation Vijay SharmaDynamics Ax Retail Installation Vijay Sharma
Dynamics Ax Retail Installation Vijay SharmaVijay Sharma
 
An Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration FrameworkAn Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration FrameworkFolio3-Dynamics-Services
 
X++ advanced course
X++ advanced courseX++ advanced course
X++ advanced courseAlvin You
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Ali Raza Zaidi
 
Dynamic AX : Application Integration Framework
Dynamic AX : Application Integration FrameworkDynamic AX : Application Integration Framework
Dynamic AX : Application Integration FrameworkSaboor Ahmed
 
Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01
Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01
Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01Ahmed Farag
 
Ax 2012 x++ code best practices
Ax 2012 x++ code best practicesAx 2012 x++ code best practices
Ax 2012 x++ code best practicesSaboor Ahmed
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuningOutsourceAX
 
Introduction to DAX
Introduction to DAXIntroduction to DAX
Introduction to DAXIke Ellis
 
Microsoft Cloud Computing
Microsoft Cloud ComputingMicrosoft Cloud Computing
Microsoft Cloud ComputingDavid Chou
 
Dimensionality & Dimensions of Hyperion Planning
Dimensionality & Dimensions of Hyperion PlanningDimensionality & Dimensions of Hyperion Planning
Dimensionality & Dimensions of Hyperion Planningepmvirtual.com
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)Katy Slemon
 
Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3Juan Fabian
 
Budgeting using hyperion planning vs essbase
Budgeting using hyperion planning vs essbaseBudgeting using hyperion planning vs essbase
Budgeting using hyperion planning vs essbaseSyntelli Solutions
 

Tendances (20)

Dynamics Ax Retail Installation Vijay Sharma
Dynamics Ax Retail Installation Vijay SharmaDynamics Ax Retail Installation Vijay Sharma
Dynamics Ax Retail Installation Vijay Sharma
 
An Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration FrameworkAn Introduction to the Dynamics AX Application Integration Framework
An Introduction to the Dynamics AX Application Integration Framework
 
Dynamics AX/ X++
Dynamics AX/ X++Dynamics AX/ X++
Dynamics AX/ X++
 
X++ advanced course
X++ advanced courseX++ advanced course
X++ advanced course
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3
 
Dynamic AX : Application Integration Framework
Dynamic AX : Application Integration FrameworkDynamic AX : Application Integration Framework
Dynamic AX : Application Integration Framework
 
Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01
Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01
Developing ssrs-reports-for-dynamics-ax-120402001948-phpapp01
 
Ax 2012 x++ code best practices
Ax 2012 x++ code best practicesAx 2012 x++ code best practices
Ax 2012 x++ code best practices
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 
Sets in Tableau
Sets in TableauSets in Tableau
Sets in Tableau
 
Introduction to DAX
Introduction to DAXIntroduction to DAX
Introduction to DAX
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
DAX (Data Analysis eXpressions) from Zero to Hero
DAX (Data Analysis eXpressions) from Zero to HeroDAX (Data Analysis eXpressions) from Zero to Hero
DAX (Data Analysis eXpressions) from Zero to Hero
 
Microsoft Cloud Computing
Microsoft Cloud ComputingMicrosoft Cloud Computing
Microsoft Cloud Computing
 
Dimensionality & Dimensions of Hyperion Planning
Dimensionality & Dimensions of Hyperion PlanningDimensionality & Dimensions of Hyperion Planning
Dimensionality & Dimensions of Hyperion Planning
 
Optimization in essbase
Optimization in essbaseOptimization in essbase
Optimization in essbase
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
 
Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
Budgeting using hyperion planning vs essbase
Budgeting using hyperion planning vs essbaseBudgeting using hyperion planning vs essbase
Budgeting using hyperion planning vs essbase
 

En vedette

AX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideAX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideBiswanath Dey
 
Ax 2012 enterprise portal development
Ax 2012 enterprise portal developmentAx 2012 enterprise portal development
Ax 2012 enterprise portal developmentMoutasem Al-awa
 
Closed Loop Marketing (CLM)
Closed Loop Marketing (CLM)Closed Loop Marketing (CLM)
Closed Loop Marketing (CLM)Sai Kumar
 
Closed-loop Marketing Analytics
Closed-loop Marketing AnalyticsClosed-loop Marketing Analytics
Closed-loop Marketing AnalyticsDavid Delong
 
Microsft Dynamics AX Introduction
Microsft Dynamics AX IntroductionMicrosft Dynamics AX Introduction
Microsft Dynamics AX IntroductionMohamed Samy
 
Developing ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-axDeveloping ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-axNicc Ngo
 

En vedette (8)

Azure overview
Azure overviewAzure overview
Azure overview
 
AX 2012 R3 Installation Guide
AX 2012 R3 Installation GuideAX 2012 R3 Installation Guide
AX 2012 R3 Installation Guide
 
Ax 2012 enterprise portal development
Ax 2012 enterprise portal developmentAx 2012 enterprise portal development
Ax 2012 enterprise portal development
 
Closed Loop Marketing (CLM)
Closed Loop Marketing (CLM)Closed Loop Marketing (CLM)
Closed Loop Marketing (CLM)
 
CRM AT A GLANCE
CRM AT A GLANCECRM AT A GLANCE
CRM AT A GLANCE
 
Closed-loop Marketing Analytics
Closed-loop Marketing AnalyticsClosed-loop Marketing Analytics
Closed-loop Marketing Analytics
 
Microsft Dynamics AX Introduction
Microsft Dynamics AX IntroductionMicrosft Dynamics AX Introduction
Microsft Dynamics AX Introduction
 
Developing ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-axDeveloping ssrs-reports-for-dynamics-ax
Developing ssrs-reports-for-dynamics-ax
 

Similaire à Microsoft Dynamics AX 2012 - X++ Compiled to CIL

Dbva dotnet programmer_guide_chapter8
Dbva dotnet programmer_guide_chapter8Dbva dotnet programmer_guide_chapter8
Dbva dotnet programmer_guide_chapter8Shakeel Mujahid
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 
01. introduction to-programming
01. introduction to-programming01. introduction to-programming
01. introduction to-programmingStoian Kirov
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
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...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...bhargavi804095
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docMayurWagh46
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1Sisir Ghosh
 
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on DatabricksCI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on DatabricksDatabricks
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - IntroductionRandy Connolly
 
414: Build an agile CI/CD Pipeline for application integration
414: Build an agile CI/CD Pipeline for application integration414: Build an agile CI/CD Pipeline for application integration
414: Build an agile CI/CD Pipeline for application integrationTrevor Dolby
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building BlocksMax Kleiner
 

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

T2
T2T2
T2
 
Dbva dotnet programmer_guide_chapter8
Dbva dotnet programmer_guide_chapter8Dbva dotnet programmer_guide_chapter8
Dbva dotnet programmer_guide_chapter8
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
01. introduction to-programming
01. introduction to-programming01. introduction to-programming
01. introduction to-programming
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
C Sharp Jn
C Sharp JnC Sharp Jn
C Sharp Jn
 
C Sharp Jn
C Sharp JnC Sharp Jn
C Sharp Jn
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on DatabricksCI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
CI/CD Templates: Continuous Delivery of ML-Enabled Data Pipelines on Databricks
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
 
414: Build an agile CI/CD Pipeline for application integration
414: Build an agile CI/CD Pipeline for application integration414: Build an agile CI/CD Pipeline for application integration
414: Build an agile CI/CD Pipeline for application integration
 
DLL Design with Building Blocks
DLL Design with Building BlocksDLL Design with Building Blocks
DLL Design with Building Blocks
 

Dernier

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Dernier (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Microsoft Dynamics AX 2012 - X++ Compiled to CIL

  • 1. Fabio Filardi Dynamics AX Technical Architect ffilardi@msbsgroup.com
  • 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.