[Mono-list] BinaryFormatter Issue

Pedro Santos donbonifacio.general@gmail.com
Sat, 27 Nov 2004 10:28:06 +0000


Oh!Just to say that SoapFormatter executes with no exceptions! 
And BinaryFormatter throws the following:

PersistenceTests.init:0# System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.ArgumentNullException: null key
Parameter name: key
in <0x00072> System.Collections.Hashtable:PutImpl (object,object,bool)
in <0x00019> System.Collections.Hashtable:Add (object,object)
in <0x003e7> System.Collections.Hashtable:.ctor
(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
in (unmanaged) (wrapper managed-to-native)
System.Reflection.MonoCMethod:InternalInvoke (object,object[])
in <0x00004> (wrapper managed-to-native)
System.Reflection.MonoCMethod:InternalInvoke (object,object[])
in <0x00097> System.Reflection.MonoCMethod:Invoke
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
--- End of inner exception stack trace ---

in <0x000fb> System.Reflection.MonoCMethod:Invoke
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
in <0x00021> System.Reflection.MethodBase:Invoke (object,object[])
in <0x00220> System.Runtime.Serialization.ObjectRecord:LoadData
(System.Runtime.Serialization.ObjectManager,System.Runtime.Serialization.ISurrogateSelector,System.Runtime.Serialization.StreamingContext)
in <0x0011c> System.Runtime.Serialization.ObjectManager:DoFixups ()
in <0x00044>
System.Runtime.Serialization.Formatters.Binary.ObjectReader:ReadNextObject (System.IO.BinaryReader)
in <0x000b1>
System.Runtime.Serialization.Formatters.Binary.ObjectReader:ReadObjectGraph (System.IO.BinaryReader,bool,object&,System.Runtime.Remoting.Messaging.Header[]&)
in <0x00191>
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter:Deserialize (System.IO.Stream,System.Runtime.Remoting.Messaging.HeaderHandler)
in <0x00017>
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter:Deserialize (System.IO.Stream)
in <0x00043> Chronos.Persistence.UniverseSerializer:load ()
in <0x005ed> Chronos.Tests.PersistenceTests:init (Chronos.IPersistence)


On Sat, 2004-11-27 at 09:50 +0000, Pedro Santos wrote:
> On Sat, 2004-11-27 at 08:47 +0000, Pedro Santos wrote:
> > Hello. I Use BinaryFormatter to serialize an Object and it runs just
> > fine. However, when I desserialize it, I get the following exception:
> > 
> > "Serializable objects must be marked with the Serializable attribute"
> > 
> > Any help on this?
> 
> Well, using SoapFormatter I got a better expcetion Message and find out
> I neglected to use [Serializable] in a nested class. Is this a bug?
> 
> However, now I have another problem. I get the following exception form
> either IFormatter:
> 
> System.Runtime.Serialization.SerializationException: The constructor to
> deserialize an object of type Chronos.Alliances.AllianceCollection was
> not found.
> 
> And I have AllianceCollection like this:
> 
> [Serializable]
> public class AllianceCollection : Hashtable {
> 
>         public AllianceCollection() {
>                 // ... some stuff
>         }
> };
> 
> Any help? If I create a ctor with the SerializationInfo and
> StreamingContext I have other several problems. What's the best way to
> serialize AllianceCollection?
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list