D365FFO – AX – What is CIL in AX 2012

n Microsoft Dynamics AX 2012, code can be compiled to CIL and run in the .NET CLR. But what does CIL mean and what is it used for?
CIL stands for Common Intermediate Language and is in essence an object-oriented assembly language. It complies with the Common Language Infrastructure (CLI), which is a specification that was developed by Microsoft to describe a set of rules which programming languages need to comply with when they are targeting the CLI. One of the most important aspects of the CIL is that it is a platform- and CPU-independent instruction set. This enables the code to be executed on different environments as long as they comply with the CLI specification.
The following diagram shows that the languages are first compiled in CIL, after which the Common Language Runtime (CLR) compiles the platform-independent CIL code into machine readable code: 

Microsoft Dynamics AX 2012 now has the ability to transform the X++ compiler’s P-Code to CIL code and therefore is able to run X++ code in CIL. This is quite a step forward as CIL is faster than X++. We also need to keep CIL in mind when developing services later on. Code that runs on the server, such as batch jobs and services, will be running in CIL and therefore X++ code needs to be compiled into CIL.

As compilation into CIL takes a long time, it is not done automatically when X++ code is compiled. We need to do this manually when code has been modified by using the new CIL compilation buttons in the developer workspace.

You can either start a full or an incremental CIL generation. The main difference between the two is that the incremental generation only regenerates the objects that were modified since the previous generation, and the full generation completely regenerates all objects. As you can imagine, the incremental process is much faster than the full process, but do keep in mind that incremental generation will not always be enough. Sometimes you will have no option than to completely regenerate CIL. No matter how you look at it, compiling CIL is not optional. Without CIL, your
services cannot run!


CIL output
So the CIL generation is done. But what has changed and where can we find the results of the process? The answer to that question can be found in the server’s bin directory. By default, the file system folder is : %ProgramFiles%\Microsoft Dynamics AX\60\Server\<Server Name>\bin\XppIL\. In this folder, you can find the resulting Dynamics.Ax.Application.dll assembly file along with a list
of NetModule files. NetModule files differ from .NET assemblies in the fact that they do not contain an assembly manifest. They only contain type metadata and compiled code. Next to these files containing the CIL code, this folder may also contain a subfolder named source. In this folder we can find files with the .xpp extension. These files contain the X++ source code and can be used when debugging CIL code in Visual Studio so that the editor and debugger can show the actual source code.

Note that the existence of the source subfolder depends on the server configuration.When the options are set to enable debugging on the server, the source folder will be generated at AOS startup. Without the options enabled you cannot debug, so the source folder will not be generated as this is not needed.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...