Skip to main content

Notifications

Announcements

No record found.

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

AX2012 Code won't run in IL

(0) ShareShare
ReportReport
Posted on by 550

Hello!

I have written some code to run it in IL, but I'm able to debug it with AX-Debugger and not at Visual Studio, so I think something goes wrong, but I don't know what.

The Code Starts at this point:

class ANXTMSWayBillComplete extends RunBase (I also tried to run it from a TableMethod)

...

            wayBillTable = ANXTMSWayBillTable::find(groupId, true);
            if(ANXTMSParameters::findOrCreate().completeWayBillIL == NoYes::No)
            {
                wayBillTable.completeWayBill();
            }
            else
            {
                ANXTMSWayBillCompleteIL::callIL(wayBillTable);
            }

There I came to line ::callIL

--> 

class ANXTMSWayBillCompleteIL
{
}

public static server container callIL(ANXTMSWayBillTable _wayBillTable)
{
    XppILExecutePermission  xppILExecutePermission = new XppILExecutePermission();
    container               result;

    xppILExecutePermission.assert();
    result = runClassMethodIL(
        classStr(ANXTMSWayBillCompleteIL),
        staticMethodStr(ANXTMSWayBillCompleteIL, completeWayBillIL),[buf2Con(_wayBillTable,true)]);

    CodeAccessPermission::revertAssert();

    return result;
}

public server static container completeWayBillIL(container _parmContainer)
{
...
}

I set a Breakepoint in Method "completeWayBillIL" and get the following Result:

AxDebugIL.png

After That, I Have created a Test Job like this:

static void SFERunIl(Args _args)
{
    SFETest sfeTest;
    container result;
    ANXTMSWayBillTable wbt = ANXTMSWayBillTable::find("A003415");
    ;

    result = ANXTMSWayBillCompleteIL::callIL(wbt);

    info(conPeek(result,1));

}

When I Run this Job, I am able to debug the Code on Server within Visual Studio:

VSDebugIL.png

I see a Different call in SysDictClass::invokeStaticMethodIL

4572.DifferentDebugIL.png

Is there some Configuration which I don't know about?

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,476 Most Valuable Professional on at
    RE: AX2012 Code won't run in IL

    I'm not sure that I understand your question. Are you wondering why isCLRSession() returns true if called from CIL and false if not? Isn't it exactly what it should be doing?

    Your job isn't executed in CIL and therefore it's necessary to create a new CLR session. The RunBase class normally executes code in CIL and if it's the case, the method is called directly. There is no reason to create a CLR session if we're already inside one.

  • Stefan Wojtas Profile Picture
    Stefan Wojtas 550 on at
    RE: AX2012 Code won't run in IL

    Okay, yes, I see the Different. You are right with TTS:

    BusinessLogic:

    parmExecuteBusinessOperationsWithCLR = true

    xSession::isCLRSession() == false;

    tts = 1

    _ignoreTtsLevel = false

    Job

    parmExecuteBusinessOperationsWithCLR =

    xSession::isCLRSession() == false;

    tts = 0

    _ignoreTtsLevel = false

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: AX2012 Code won't run in IL

    Good, so you ruled out one of the three statements. Now we know that this setting is not explaining the difference.

    Next you move to the remaining 2 statements and find out which one of them causes the difference.

  • Stefan Wojtas Profile Picture
    Stefan Wojtas 550 on at
    RE: AX2012 Code won't run in IL

    Yes, I found this:

    docs.microsoft.com/.../debug-in-interpreted-mode-your-x-code-that-runs-as-net-cil

    But, when I uncheck the Box, the Job also run into the first condition.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: AX2012 Code won't run in IL

    Did you find out why it goes to the different condition in the last screenshot? You can see what conditions it evaluates so please find out which one causes it to work differently.

    By looking at the code, for example tts level could cause it.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans