[Mono-bugs] [Bug 649620] New: Invalid serialization of datetime

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Oct 27 12:01:15 EDT 2010



           Summary: Invalid serialization of datetime
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: 64bit
        OS/Version: RHEL 5
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: srfcanada at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64;
Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; MS-RTC LM 8)

the following test case works on windows but fails on mono. Note that this used
to work as of a couple weeks ago so it seems to have been broken recently.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.IO;

   class monofail6
      static int Main(string[] args)

         DateTime dtm = new DateTime(2010, 7, 7, 10, 10, 10, 10,
         LocalDateTime localDateTime = new LocalDateTime(dtm);

         BinaryFormatter bf = new BinaryFormatter();
         MemoryStream ms = new MemoryStream();
         bf.Serialize(ms, localDateTime);
         ms.Position = 0;

         LocalDateTime dateTime2 = (LocalDateTime)bf.Deserialize(ms);

         Console.WriteLine("Original Date:" + dtm.ToString());
         Console.WriteLine("Current  Date:" + dateTime2);

         if (dtm != dateTime2.DateTime)
            throw new Exception("dates are not equal!!");

         return 0;

      public struct LocalDateTime : ISerializable
         private DateTime m_localDateTime;
         public LocalDateTime(DateTime dt)
            m_localDateTime = dt;

         private LocalDateTime(SerializationInfo info, StreamingContext
            m_localDateTime =

         public DateTime DateTime
            get { return m_localDateTime; }
            set { m_localDateTime = value; }

         void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext context)
            info.AddValue("LocalDateTime", m_localDateTime.ToBinary());

         public override string ToString()
            return m_localDateTime.ToString();


Reproducible: Always

Steps to Reproduce:

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list