DateTime.ToString in Mono return invalid date (“00/734718/0001 01:41:38”)

后端 未结 4 1956
耶瑟儿~
耶瑟儿~ 2021-01-02 02:17

I am trying to get mono (Debian 2.10.8.1-5) to run properly on my raspberry pi with the raspbian distro (\"Debian GNU/Linux wheezy/sid\"). I have installed mono with apt-get

相关标签:
4条回答
  • 2021-01-02 02:46

    That's most likely to be an ARM Mono binary layer bug. Especially since you are running a version that was release before Raspberry Pi. You will have much better luck with that on mono-devel mailing list. And it's possible that this is fixed in git already.

    0 讨论(0)
  • 2021-01-02 02:53

    I can't reproduce your issue on Windows (don't have raspberry, but your subject says Mono).

    I copied and pasted your exact source for Main() into a new Mono console app (Mono 2.6.1), added a single line (Console.ReadLine();), and ran it:

    using System;
    
    namespace TestDateTimeNow
    {
    
      class MainClass
      {
        public static void Main (string[] args)
        {
            DateTime now = DateTime.Now;
            Console.WriteLine("Year: " + now.Year);
            Console.WriteLine("Month: " + now.Month);
            Console.WriteLine("Day: " + now.Day);
            Console.WriteLine("DayOfWeek: " + now.DayOfWeek);
            Console.WriteLine("DateTime.Now: " + DateTime.Now);
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd"));
            Console.ReadLine();
        }
      }
    }
    

    I get the output below:

    Mono App Console App Output

    0 讨论(0)
  • 2021-01-02 02:58

    You need to use the soft floating point OS for this. 2013-05-29-wheezy-armel.zip for example.

    The hard floating point doesn't work well with JITers. I had the same issue, resolved it by installing the soft floating point version of the OS on my RP. I wouldn't recommended using .net with a hard floating point OS under the raspberry pi platform. Hope this helps.

    0 讨论(0)
  • 2021-01-02 03:05

    This is Mono bug #7938, and it affects not just DateTime.ToString, but ANY function that, directly or indirectly, passes a floating-point number to a library call, when running on ARM with a Linux distro built for the hard-float ABI. More details are available at the C# on Raspberry Pi wiki page. There is currently no good fix for this, short of running a soft-float distro. I'm still hoping we can get a fixed mono runtime soon.

    0 讨论(0)
提交回复
热议问题