[Mono-list] OnDeserialized exception

Jonathan Gagnon jonathan.gagnon at croesus.com
Wed Oct 17 10:32:24 EDT 2007


Lately, I started using the OnDeserialized event to do some stuff after an
object is deserialized.  It works fine when I compile it on my machine,
unfortunately, when compiled on our build machine, I get the following error
when deserializing my object with mono :
 
System.NotSupportedException: Collection is read-only
  at System.Array.InternalArray__RemoveAt[Object] (Int32 index) [0x00000] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System/Array.cs:131
  at (wrapper managed-to-managed)
Croesus.EntityManagement.IAccessControlInformation[]:System.Collections.Gene
ric.IList`1.RemoveAt (int)
  at (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_StreamingContext
(System.Runtime.Serialization.StreamingContext)
  at System.Runtime.Serialization.SerializationCallbacks.Invoke
(System.Collections.ArrayList list, System.Object target, StreamingContext
context) [0x00064] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n/SerializationCallbacks.cs:116
  at System.Runtime.Serialization.SerializationCallbacks.RaiseOnDeserialized
(System.Object target, StreamingContext contex) [0x00000] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n/SerializationCallbacks.cs:136
  at System.Runtime.Serialization.ObjectManager.RaiseOnDeserializedEvent
(System.Object obj) [0x0000c] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n/ObjectManager.cs:186
  at System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent ()
[0x00025] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n/ObjectManager.cs:162
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject
(System.IO.BinaryReader reader) [0x0001a] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n.Formatters.Binary/ObjectReader.cs:117
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph
(System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result,
System.Runtime.Remoting.Messaging.Header[]& headers) [0x00042] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n.Formatters.Binary/ObjectReader.cs:105
  at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeseri
alize (System.IO.Stream serializationStream,
System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00077] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n.Formatters.Binary/BinaryFormatter.cs:172
  at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
(System.IO.Stream serializationStream) [0x00000] in
/tmp/scratch/BUILD/mono-1.2.3.1/mcs/class/corlib/System.Runtime.Serializatio
n.Formatters.Binary/BinaryFormatter.cs:129
  at Croesus.FrameworkServerInterface.FrameworkSocket.ReadObject ()
[0x00008] in
c:\DailyBuild\Sources\70.0101-CFF\Foundations\FrameworkComponents\FrameworkS
erverInterface\FrameworkSocket.cs:493
  at
Croesus.FrameworkServer.RequestProcessing.ClientConnectionHandler.ReceiveReq
uest (ReadStatus readStatus) [0x0001f] in
c:\DailyBuild\Sources\70.0101-CFF\Products\FrameworkServer\RequestProcessing
\ClientConnectionHandler.cs:168

In both cases, everything is compiled using Visual Studio 2005.  The
compiled dlls are different when I compare them with a binary diff, but if I
use the reflector to dump the source code, they are identical.  So
basically, the reflector sees both dlls as identical, but mono can't handle
one of them.  .NET works fine with both.  I tried recompiling the dlls many
times on both machines.  It seems that Visual Studio produces different
binaries every time, but there is one constant, the one I compile on my
machine works and the one I compile on the build machine doesn't.
 
Looking at the call stack of the error, it seems like the delegate doesn't
call the right method.  It doesn't call the method that I identified with
the OnDeserialized attribute, it calls InternalArray__RemoveAt instead,
which triggers the error.
 
Any idea what could be the source of that problem?  I'm using mono 1.2.3.1.
I will try with the latest sources ASAP.
 
Thanks,
 
Jonathan Gagnon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20071017/1d7dc51e/attachment.html 


More information about the Mono-list mailing list