S
semedao
Hi All,
I had working code that made custom serialization on objects that inherit from queue
in the inherited queue I create my own GetObjectData:
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
lock (this.SyncRoot)
{
IEnumerator Ienum = this.GetEnumerator();
int i = 0;
MyObj _Obj = null;
while (Ienum.MoveNext())
{
i++;
_Obj = (MyObj)Ienum.Current;
info.AddValue("MyObj_" + i.ToString(), Ienum.Current);
}
info.AddValue("Count", i);
info.AddValue("StoreFileName", StoreFileName);
}
}
this code work correctly
after move couple of methods from internal class to the parent class ( I don't speak about the classes that make the serialization , only about the class that call the code that Will cause the serialization in my inherited queue objects )
I start to receive :
Fail: Type 'System.Net.Sockets.Socket' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
Fail: Type 'System.Net.Sockets.Socket' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable. at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at ... -> here is my hosted class that call the method that cause the serialization
I don't have any Socket objects not in the my queue class nor in the inside object !
also when debugging step by step the Exception thrown without any control not in specific line!
any suggestions ?
thanks
I had working code that made custom serialization on objects that inherit from queue
in the inherited queue I create my own GetObjectData:
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
lock (this.SyncRoot)
{
IEnumerator Ienum = this.GetEnumerator();
int i = 0;
MyObj _Obj = null;
while (Ienum.MoveNext())
{
i++;
_Obj = (MyObj)Ienum.Current;
info.AddValue("MyObj_" + i.ToString(), Ienum.Current);
}
info.AddValue("Count", i);
info.AddValue("StoreFileName", StoreFileName);
}
}
this code work correctly
after move couple of methods from internal class to the parent class ( I don't speak about the classes that make the serialization , only about the class that call the code that Will cause the serialization in my inherited queue objects )
I start to receive :
Fail: Type 'System.Net.Sockets.Socket' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
Fail: Type 'System.Net.Sockets.Socket' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable. at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at ... -> here is my hosted class that call the method that cause the serialization
I don't have any Socket objects not in the my queue class nor in the inside object !
also when debugging step by step the Exception thrown without any control not in specific line!
any suggestions ?
thanks