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)

Converting double type to string using invariant culture crashes the client

(0) ShareShare
ReportReport
Posted on by

Hi,

For the purposes of serializing some real data to XML I'm using .Net libraries to format real to double and then to string. Here's a simple code:

static void Job42(Args _args)
{
    real QtyFactor = 0.5;
    System.Double netDouble;
    str val;

    netDouble = Global::real2double(QtyFactor);
    if (QtyFactor > 0.0 && QtyFactor < 1.0) breakpoint;
    val = netDouble.ToString("F", new System.Globalization.CultureInfo(""));
info(val); }

The code compiles just fine. However when execution goes over the line with ToString() call the entire AX client bugs out with crash. Restarting AOS does not help.

Should I change the code as follows everything works and prints "0,5":

static void Job42(Args _args)
{
    real QtyFactor = 0.5;
    System.Double netDouble;
    str val;

    netDouble = Global::real2double(QtyFactor);
    if (QtyFactor > 0.0 && QtyFactor < 1.0) breakpoint;
    val = netDouble.ToString();
    info(val);
}

Any ideas?

*This post is locked for comments

I have the same question (0)
  • psined Profile Picture
    on at

    Should I change the code as follows, everything works:

    static void Job42(Args _args)
    {
        real QtyFactor = 324234.5345235345345;
        System.Double netDouble;
        str val;
        System.Globalization.CultureInfo ci = System.Globalization.CultureInfo::get_InvariantCulture();
    
        netDouble = Global::real2double(QtyFactor);
        //if (QtyFactor > 0.0 && QtyFactor < 1.0) breakpoint;
        //the following works the same as - num2str(QtyFactor, 0, 17, 1, 0);
        val = netDouble.ToString("F", ci);
        info(val);
    }

  • psined Profile Picture
    on at

    while the above workaround works for me, it seems like there is a CLR marshaling issue with certain datatypes in AX runtime

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