Wednesday, December 4, 2013

Dynamics AX: Compile, Generate (CIL), and Restart (AOS)

In AX development, it is a bit confusing about the real meaning of “compile”,  “generate full CIL or incremental CIL”, and in which cases need to restart AOS instance(s), but I believe it is import to make clear about it.

 To compile is to convert x++ source code into p-code, while to generate CIL is about to convert the p-code into CIL – the common intermediate language, referred to as the byte code which, at run time, is used by the CLR to convert into native code for execution on the computer. It is easier to understand that a full CIL generation involves converting all p-code into CIL whereas an incremental CIL generation involves only the “changed” p-code artifacts that need  to be converted into target CIL.

 Even CIL generation involves the model store update in the database, a critical observation is that it updates .dll files in the XppIL folder under the AOS installation folders. In other words, it updates the assemblies used by the AOS service. This is an implication for restarting  the AOS.  Note, usually we don’t need to restart the AOS due to the CIL generation is through the AOS instance, i.e. the AOS instance is automatically "reloaded" the newly generated assemblies. And this is why when we use load balance, we need to restart all AOS instances other than the one with that we generate the CIL.

 The X++ compiler is triggered automatically when we save source code. It does the syntax check and p-code generation from the source code. But CIL generation is not automatic, neither AOS to restart, when needed.

 One might wonder why not a single step to compile x++ source code into CIL, but rather through p-code? In fact, the system keeps p-code and CIL for the same objects, and these objects can run through both CLR and p-x++ interpreter respectively. I believe it is a historical reason – the early product has nothing to do with .Net platform, but now it evolves into that direction.

1 comment:

Unknown said...

Stay committed to your decisions, but stay flexible in your approach. See the link below for more info.

#committed
www.ufgop.org