mail-archives/mono-bugs/2010-October/105526.html

232 строки
5.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 649620] New: Invalid serialization of datetime
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20649620%5D%20New%3A%20Invalid%20serialization%20of%20datetime&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="105525.html">
<LINK REL="Next" HREF="105527.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 649620] New: Invalid serialization of datetime</H1>
<B>bugzilla_noreply at novell.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20649620%5D%20New%3A%20Invalid%20serialization%20of%20datetime&In-Reply-To="
TITLE="[Mono-bugs] [Bug 649620] New: Invalid serialization of datetime">bugzilla_noreply at novell.com
</A><BR>
<I>Wed Oct 27 12:01:15 EDT 2010</I>
<P><UL>
<LI>Previous message: <A HREF="105525.html">[Mono-bugs] [Bug 366466] Detached console application hangs when Console is initialized
</A></li>
<LI>Next message: <A HREF="105527.html">[Mono-bugs] [Bug 649620] Invalid serialization of datetime
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#105526">[ date ]</a>
<a href="thread.html#105526">[ thread ]</a>
<a href="subject.html#105526">[ subject ]</a>
<a href="author.html#105526">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>
<A HREF="https://bugzilla.novell.com/show_bug.cgi?id=649620">https://bugzilla.novell.com/show_bug.cgi?id=649620</A>
<A HREF="https://bugzilla.novell.com/show_bug.cgi?id=649620#c0">https://bugzilla.novell.com/show_bug.cgi?id=649620#c0</A>
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: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">srfcanada at hotmail.com</A>
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
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,
DateTimeKind.Local);
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(&quot;Original Date:&quot; + dtm.ToString());
Console.WriteLine(&quot;Current Date:&quot; + dateTime2);
if (dtm != dateTime2.DateTime)
throw new Exception(&quot;dates are not equal!!&quot;);
Console.WriteLine(&quot;Worked!!&quot;);
return 0;
}
[Serializable]
public struct LocalDateTime : ISerializable
{
private DateTime m_localDateTime;
public LocalDateTime(DateTime dt)
{
m_localDateTime = dt;
}
private LocalDateTime(SerializationInfo info, StreamingContext
context)
{
m_localDateTime =
DateTime.FromBinary(info.GetInt64(&quot;LocalDateTime&quot;));
}
public DateTime DateTime
{
get { return m_localDateTime; }
set { m_localDateTime = value; }
}
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext context)
{
info.AddValue(&quot;LocalDateTime&quot;, m_localDateTime.ToBinary());
}
public override string ToString()
{
return m_localDateTime.ToString();
}
}
}
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
--
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="105525.html">[Mono-bugs] [Bug 366466] Detached console application hangs when Console is initialized
</A></li>
<LI>Next message: <A HREF="105527.html">[Mono-bugs] [Bug 649620] Invalid serialization of datetime
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#105526">[ date ]</a>
<a href="thread.html#105526">[ thread ]</a>
<a href="subject.html#105526">[ subject ]</a>
<a href="author.html#105526">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>