[Mono-list] OnDeserialization problem

Dave Null eric.jacoboni at gmail.com
Thu Feb 26 16:44:15 EST 2009


Hi,

I'm trying to use the IDeserializationCallback interface with Mono 2.2  on
OS X 1.5.6 :

% mono --version
Mono JIT compiler version 2.2 (tarball Fri Jan  9 10:45:07 MST 2009)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
	TLS:           normal
	GC:            Included Boehm (with typed GC)
	SIGSEGV:       normal
	Notification:  Thread + polling
	Architecture:  x86
	Disabled:      none

For my test, i've simply created a class which implements the interface and
the OnDeserialization() method :

[Serializable] class Truc : IDeserializationCallback {
	private int limite;
	[NonSerialized] private int[] tab;
       (...)
       public virtual void OnDeserialization(Object sender) {
	  for (int i = 0; i < limite; i++) {
	    tab[i] = i + 42;
	  }
	}
       public static void Main() {
	  Truc truc = new Truc(20);
	  Console.WriteLine(truc);
	  truc.Dump();
	  Truc machin = Truc.Load();
	  Console.WriteLine(machin);
	}
}

This code compile fine with gmcs but execution throws an
System.NullReferenceException :

% mono serialisation2.exe
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 

Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object
  at Truc.OnDeserialization (System.Object sender) [0x00000] 
  at System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent ()
[0x00000] 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject
(System.IO.BinaryReader reader) [0x00000] 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph
(System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result,
System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000] 
  at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize
(System.IO.Stream serializationStream,
System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] 
  at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
(System.IO.Stream serializationStream) [0x00000] 
  at Truc.Load () [0x00000] 
  at Truc.Main () [0x00000] 

Any clue ?



-- 
View this message in context: http://www.nabble.com/OnDeserialization-problem-tp22234369p22234369.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list