Tuesday, March 15, 2016

CIL Code in AX 2012

Often you must be looking into the the message, ".....Generate incremental CIL before running CIL code" when any AOT class, table or project you are going to compile


I recommend you to understand the concept of CIL because some times your changes doesn't show any effect even after compiling the code. The main reason behind this could be because the CIL code is not generated. I am giving you an example for this. I added few fields recently in performa invoice every time I clicked performa invoice the fields that were added were not showing any modified value. In order to address this thing, I tried many things but it didn't work eventually I generated incremental CIL and then it started working!!. It is quite evident from this there has been CIL code behind performa invoice which has to be generated. Also I am writing few things related to CIL and concept of CIL bellow.



Concept of CIL, Why CIL?

At first let's understand  the concept of  "CIL" in Dynamics AX. There are multiple blogs are written already to elaborate the concept of CIL. Here I am writing few lines in my own words.

CIL is common intermediate language which is low level language used by .NET framework.  And as most of you guys must be aware of the concept of CLR which is actually the run-time environment provided by the .NET framework. CLR understands "CIL", it doesn't work directly with high level languages such as C#, Visual Basic or X++.

Dynamics AX 2012 is able to generate Common Intermediate Language from X++.  As this diagram shows, that AX 2012 has the ability to compile P-Code to CIL, and therefore AX 2012 is able to run X++ code directly into the CIL, which is much faster the P-Code compiler we had before.



This above snapshot is taken from the source:- http://axwonders.blogspot.in/2013/04/ax-2012-cil-how-does-it-work.html, which explains the same process in detail.

The major benefit of using CIL is due to the fact that converting the X++ code to CIL will have very positive impact on performance such as switching between X++ run-time and CLR can greatly be reduced.

Further I would recommend you to read these two blogs

http://dev.goshoom.net/en/2013/03/x-to-cil/
http://axwonders.blogspot.com/2013/04/ax-2012-cil-how-does-it-work.html