[Mono-bugs] [Bug 70757][Nor] New - Serialization - Unsupported primitive type: System.IntPtr

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 22 Dec 2004 15:46:29 -0500 (EST)


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 sebastien@ximian.com.

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

--- shadow/70757	2004-12-22 15:46:29.000000000 -0500
+++ shadow/70757.tmp.1449	2004-12-22 15:46:29.000000000 -0500
@@ -0,0 +1,106 @@
+Bug#: 70757
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Serialization - Unsupported primitive type: System.IntPtr
+
+Description of Problem:
+System.IntPtr is no more supported when serializing an object. This was
+working last time I checked. A unit test for WindowsIdentity started
+failing because of this.
+
+Steps to reproduce the problem:
+1. Compile this
+
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+
+[Serializable]
+public class IntPtrBug {
+	private IntPtr _buggyboo;
+}
+
+public class Program {
+
+	static public int Main (string[] args)
+	{
+		IntPtrBug bug1 = new IntPtrBug ();
+		MemoryStream ms = new MemoryStream ();
+		IFormatter formatter = new BinaryFormatter ();
+		formatter.Serialize (ms, bug1);
+		ms.Position = 0;
+		IntPtrBug bug2 = (IntPtrBug) formatter.Deserialize (ms);
+		return 0;
+	}
+}
+
+2. Execute with Mono runtime (HEAD)
+
+mono bug.exe
+
+3. Execute with MS runtime (tried 1.1)
+
+mono bug.exe
+
+
+Actual Results (mono):
+Unhandled Exception: System.NotSupportedException: Unsupported primitive
+type: System.IntPtr
+in <0x0023a>
+System.Runtime.Serialization.Formatters.Binary.CodeGenerator:EmitWritePrimitiveValue
+(System.Reflection.Emit.ILGenerator,System.Type)
+in <0x00d37>
+System.Runtime.Serialization.Formatters.Binary.CodeGenerator:GenerateMetadataType
+(System.Type,System.Runtime.Serialization.StreamingContext)
+in <0x00033>
+System.Runtime.Serialization.Formatters.Binary.ObjectWriter:CreateMemberTypeMetadata
+(System.Type)
+in <0x00494>
+System.Runtime.Serialization.Formatters.Binary.ObjectWriter:GetObjectData
+(object,System.Runtime.Serialization.Formatters.Binary.TypeMetadata&,object&)
+in <0x00044>
+System.Runtime.Serialization.Formatters.Binary.ObjectWriter:WriteObject
+(System.IO.BinaryWriter,long,object)
+in <0x00125>
+System.Runtime.Serialization.Formatters.Binary.ObjectWriter:WriteObjectInstance
+(System.IO.BinaryWriter,object,bool)
+in <0x00033>
+System.Runtime.Serialization.Formatters.Binary.ObjectWriter:WriteQueuedObjects
+(System.IO.BinaryWriter)
+in <0x00043>
+System.Runtime.Serialization.Formatters.Binary.ObjectWriter:WriteObjectGraph
+(System.IO.BinaryWriter,object,System.Runtime.Remoting.Messaging.Header[])
+in <0x00226>
+System.Runtime.Serialization.Formatters.Binary.BinaryFormatter:Serialize
+(System.IO.Stream,object,System.Runtime.Remoting.Messaging.Header[])
+in <0x00015>
+System.Runtime.Serialization.Formatters.Binary.BinaryFormatter:Serialize
+(System.IO.Stream,object)
+in <0x0007c> Program:Main (string[])
+
+
+Expected Results (MS runtime):
+no output
+
+
+How often does this happen? 
+Always
+
+
+Additional Information:
+* ObjectWriter doesn't have the code to process IntPtr.
+* I didn't try if this affected Mono 1.0.x