[Mono-bugs] [Bug 82400][Nor] Changed - DateTime binary serialization incompatible with MS.NET 2.0

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Aug 15 14:01:01 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jaebird at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=82400

--- shadow/82400	2007-08-15 13:52:44.000000000 -0400
+++ shadow/82400.tmp.21885	2007-08-15 14:01:01.000000000 -0400
@@ -92,6 +92,40 @@
 [{1},{2}].", 
       ticks, MinValue.Ticks, MaxValue.Ticks);
     throw new ArgumentOutOfRangeException ("ticks", msg);
   }
 }
 
+
+------- Additional Comments From jaebird at gmail.com  2007-08-15 14:01 -------
+Using Lionel's patch does not fix the Binary serialization that
+remoting is using because DateTime is considered a primitive type.
+This means it doesn't get checked for the implementation of
+ISerializable (so it doesn't go down that path). As a primitive it
+calls this method in
+corlib/System.Runtime.Serialization.Formatters.Binary.ObjectReader.cs:
+
+public static object ReadPrimitiveTypeValue (BinaryReader reader, Type
+type)
+{
+  if (type == null) return null;
+  switch (Type.GetTypeCode (type))
+  {
+    case TypeCode.Boolean:
+      return reader.ReadBoolean();
+    .
+    .
+    .
+    case TypeCode.DateTime: 
+      return new DateTime (reader.ReadInt64());
+    .
+    .
+    .
+  }
+
+If you look at the patch you will realize that the format is no longer
+ticks, it is "ticks" plus "dateData" which includes the new
+DateTimeType value as the most significant nibble of the ulong. This
+is why the DateTime ctor throws; it is range checking the ticks.
+
+The path needs to be altered so that ISerializable is used to
+serialize and deserialize DateTime primitive type.


More information about the mono-bugs mailing list