IL Compiles Explained

I've been asked several times what a Full or Incremental IL
Compile is in AX 2012.  If you have that same question here is some
background information.  IL stands for Intermediate Language it is short
for CIL - Common Intermediate Language.  When you write code in Visual
Studio (VS) you can write in many different languages, Visual Basic, C#, F# -
there are lots of choices.  In VS when you build or compile your project
those languages are all mapped down to a different language - the Common
Intermediate Language.  That means if you are writing in Visual Basic your
if/else statement in Visual Basic becomes whatever the equivalent is in
CIL.  The Common Language Runtime (CLR) that ships with .NET understands
the Common Intermediate Language and knows how to execute that code.  The
CLR does not need to understand all of the different languages (like C#, VB or
F#) it needs to only understand the one language they all get mapped down to,
CIL. 

In AX you program in X++ and the equivalent of AX's CLR is
the kernel.  When you build or compile your X++ code it traditionally gets
mapped down to a p-code language that the kernel understands and knows how to
execute.  In AX 2012 for certain classes that is what has changed.
Now when you compile the X++ code gets mapped down to the Common Intermediate
Language.  Then the CLR understands what the code says and executes it -
the kernel is not needed.

In AX 2012 there are two different kinds of compiles you can
run: a full or an incremental compile.  A full compile goes through all of
the X++ code in your AX environment and compiles the classes that run in batch
and service classes down to CIL.  A full IL compile takes a lot of memory!
You'll need at least 4 gig of memory free on the machine and I'd get more if
you can.  If you are trying to run a full IL compile and your system keeps
crashing, you need more memory.  An incremental compile maps all of the
service classes and classes running in batch to CIL that have changed since you
last ran a IL compile.  While you are doing development work you generally
only need to do an incremental compile since when your system was installed
part of the checklist involves running a full compile.

If you are having problems doing an incremental compile I
would dig into whatever errors the compiler is giving you, you probably have
something wrong in your code.  When you build your code with the X++
compiler (the compile button on the toolbar) that compiler is less stringent
about what qualifies as a compile error than the IL compiler is.  If the
X++ compiler compiles successfully but when you go to the Build > Generate
Incremental CIL option it fails, you likely have an issue in your code.
Look at which line the error message says is wrong in the description field of
the output and not at the line field.

Lastly if you get IL compilation errors you should stop and
figure them out before you proceed.  If your code does not compile, you
will run into issues where you have modified a class but your modifications are
not being used or when you call a service it does not see your changes.
Your changes are not being seen because they have not yet been compiled down to
IL code and therefore the CLR does not see them and is not trying to execute
them.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.