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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Cast error if code is running in CIL

(0) ShareShare
ReportReport
Posted on by 3,325

Hi

Got an error if code runs in CIL. Call IL method with Job:

conreq = ['output reverse']
conret = Global::StrReverseIL(conreq);

public static server container StrReverseIL(container _str)
{
    container   conparm = _str,
                conret;

    new XppILExecutePermission().assert();

    conret = Global::runClassMethodIL(classStr(Global), staticMethodStr(Global, strReverse), conparm);

    CodeAccessPermission::revertAssert();

    return conret;
}

System.InvalidCastException: Unable to cast object of type 'System.Object[]' to type 'System.String'.
   at Global::strReverse(Object[] )
   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
   at Dynamics.Ax.Application.SysDictClass.invokeStaticMethod(Object[] _params) in SysDictClass.invokeStaticMethod.xpp:line 26
   at SysDictClass::invokeStaticMethod(Object[] )
   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
   at Microsoft.Dynamics.Ax.Xpp.PredefinedFunctions.runAsInvoke(String className, String staticMethodName, Object[] parms, Object[]& exportInfolog)

The table SysXppAssembly and XppIL was cleand up bevor running new CIL.

Any idea what have to be changed?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,082 Most Valuable Professional on at

    The method executed through runClassMethodIL() must have a single parameter of type container. It's not the case of strReverse(), which expects a string.

  • Jan M. Profile Picture
    3,325 on at

    Of course we changed the strReverse() input/output to container, otherwhise you cannot run the code client- or serverside what works fine. The problem now exist only if running in CIL.

  • Martin Dráb Profile Picture
    239,082 Most Valuable Professional on at

    "Of course" isn't appropriate here - I couldn't expect you would introduce such a bug. Now your application won't even compile, because all places using strReverse() are now incompatible with the new method definition. Never ever change the type of parameters or the return value from the definition in system layers.

    Revert strReverse() to the original state, create a new method for calling by runClassMethodIL(), compile the application and generate CIL. Then try it again. If it still doesn't work, show us your code.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans