Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Can someone explain exactly what CIL code is?

Posted on by 115

We have a very customized system using AX 2012, and sometimes we run into issues where we have to turn off CIL code in order to avoid errors with certain functionality.  I don't understand what CIL code is, as opposed to "normal" code, and everyone I've asked has given me different answers, which leads me to believe that very few people actually know the truth.  I don't get the concept of having two different kinds of code that are both executable.  I'm used to writing c++ programs that have a main function, can link to some libraries, and compile into an executable.  The concept of having code that can be turned off is foreign to me and I really don't see the purpose.  Thank you.

  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Can someone explain exactly what CIL code is?

    If you write X++ code and you want to run in CIL, you obviously must generate CIL code first. Otherwise you execute CIL that was generated before, and it doesn't contain your latest changes. The incremental build is usually sufficient.

    The information message doesn't know whether you'll want to execute your changes in CIL; it's just a reminder.

  • AXGreenHorn Profile Picture
    AXGreenHorn 115 on at
    RE: Can someone explain exactly what CIL code is?

    Martin,

    What I was trying to get at is that I've run into situations where I compile the code, but it won't work properly unless I do a CIL compile.  Then I don't know whether an incremental or full CIL is required.  Also, I have seen cases where I compile the code and a info box pops up saying I need to do an incremental compile to have the changes apply, but the changes were actually effective without having to have run the incremental.  I find it very confusing, which is why I felt it might help to know what kind of code I'm working with.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Can someone explain exactly what CIL code is?

    Often you don't know whether some code will be called by X++ runtime or CLR, and you shouldn't care. You write a piece of logic and it should work regardless if it's called from a form, from a batch, from a web service or anything else. Only if you have special needs, you need to make special arrangements. An example is using client-bound objects in a process that could be executed on server.

    Sometimes it's clear that you're working on a class created from a form, for instance, therefore you know that it won't run in CIL (there is no CIL on client). But you normally don't need to think about it.

    Regarding the parameter, is it a user option at all? I thought it's only available from the developer workspace - you can use it to simplify debugging (documentation from Microsoft: Debug in Interpreted Mode Your X++ Code that Runs as .NET CIL). Needless to say that development and debugging shouldn't be done in production.

    Also note that the checkbox is specifically about the business operation (SysOperation) framework; some components such as batch jobs will still run in CIL even if you turn off the parameter.

    Your last question is why Microsoft keep something that we use only in certain situations. The answer is - because it's beneficial in those situations when we can use it. The key difference is performance - native code instead of interpreted X++, compiler optimizations, better garbage collection and so on.

  • AXGreenHorn Profile Picture
    AXGreenHorn 115 on at
    RE: Can someone explain exactly what CIL code is?

    Martin,

    I read your article.  However, there are some points I still don't understand.  First, how do you know if the particular code you are customizing will be CIL or X++ compiled code?  You state that CIL is limited to classes, tables, enums, and server methods, but it's still possible that you could be working on a class that will compile to x++ (P code?) right?   Second, if CIL comprises a significant part of AX, why is it an option to just turn it off and make all of that code non-functioning?  As you say, you shouldn't do that in general, and it makes me question why CIL is even used if there may be situations in which you would just not even use that code.

  • Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Can someone explain exactly what CIL code is?

    Hello AXGreenHorn,

    Please let us know if your question has been answered.

    If it has, then mark the answers as verified.

    Many thanks for your support.

    Ludwig

  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Can someone explain exactly what CIL code is?

    By the way, you normally shouldn't have to turn off CIL. It sounds like you have bugs in some functionality and you use this workaround instead of fixing the bugs.

    It's true that AX 2012 is bit schizophrenic - older versions used X++ runtime and F&O uses CIL; AX 2012 is a step in between.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Can someone explain exactly what CIL code is?

    The blog post mentioned above is good. Just as an addition, I covered some extra details in my blog post X++ to CIL.

  • Verified answer
    Satish Panwar Profile Picture
    Satish Panwar 14,645 on at
    RE: Can someone explain exactly what CIL code is?

    The link below provides good explanation. See if this helps.

    axinfist.blogspot.com/.../what-is-cil-in-ax-2012.html

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans