web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
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?

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    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.

  • Stefan Wojtas Profile Picture
    550 on at

    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.

  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    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
    550 on at

    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

  • Suggested answer
    Martin Dráb Profile Picture
    238,069 Most Valuable Professional on at

    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.

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 679 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 429 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 264 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans