[Mono-bugs] [Bug 68567][Maj] New - Serialization fails for MarshalByRefObjects

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 19 Oct 2004 19:27:44 -0400 (EDT)


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 rbo@acm.org.

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

--- shadow/68567	2004-10-19 19:27:44.000000000 -0400
+++ shadow/68567.tmp.22716	2004-10-19 19:27:44.000000000 -0400
@@ -0,0 +1,51 @@
+Bug#: 68567
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 2.6.8-gentoo-r10 (no nptl)
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rbo@acm.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Serialization fails for MarshalByRefObjects
+
+using System;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+using NUnit.Framework;
+
+[Serializable]
+public class Foo : MarshalByRefObject
+{
+	public string Name;
+}
+
+[TestFixture]
+public class MBROTestFixture
+{
+	[Test]
+	public void MarshalByRefObjectMustBeSerializable()
+	{
+		Foo foo = new Foo();
+		foo.Name = "Eric";
+		
+		Foo clone = (Foo)SerializeDeserialize(foo);
+		Assert.AreEqual(foo.Name, clone.Name);
+	}
+	
+	object SerializeDeserialize(object obj)
+	{
+		BinaryFormatter f = new BinaryFormatter();
+		MemoryStream stream = new MemoryStream();
+		f.Serialize(stream, obj);
+		stream.Position = 0;
+		return f.Deserialize(stream);
+	}
+}