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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

String.Format Method not work in CIL

(0) ShareShare
ReportReport
Posted on by 16,444

Hi Guys

The code below don't work in CIL.

If i try to execute on CIL, the result is Microsoft.Dynamics.Ax.Xpp.AxShared.Date and not 2/3/2014

You have find an similar issue ?

Any suggest ?

Regards

 

System.Object[] arrObjs = new System.Object[1]();  

Description retCurrent;                                                

arrObjs.SetValue( systemDateGet(), 0);

retCurrent = System.String::Format(System.Globalization.CultureInfo::GetCultureInfo("en-us"), "{0:d}", arrObjs);

info (retCurrent);

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Klaas Deforche Profile Picture
    2,433 on at

    Hi Denis,

    Cast it to a System.DateTime first:

       System.Object[] arrObjs = new System.Object[1]();  

       Description retCurrent;                                                

       System.DateTime dt;

       dt = systemDateGet();

       arrObjs.SetValue(dt, 0);

       retCurrent = ClrInterop::getAnyTypeForObject(System.String::Format(System.Globalization.CultureInfo::GetCultureInfo("en-us"), "{0:d}", arrObjs));

       info (retCurrent);

  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi Klaas

    Thanks for your reply.

    I have cast the datetime and now work.

    For a test, i have removed the cast, compiled CIL and now work also.. strange...

    I'm a little bit confuse...

    Regards

  • Klaas Deforche Profile Picture
    2,433 on at

    Yes, it is strange. It definitely not good when you get different results with or without CIL.

    Good thing you're problem is fixed :).

  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi

    Just for know, i used the standard class RetailENInfo method formatDatetimeData that don't use System.String::Format method, but System.DateTime.ToString(...

    Best Regards

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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans