Yoav

Yoav

  • NA
  • 27
  • 0

Serializing and DeSerializing The type "System.Threading.ReaderWriterLock"

Oct 3 2003 5:55 AM
I am using a RBTree class in one of my projects (I did not write this class). The RBTree class contains a data member of the type "System.Threading.ReaderWriterLock". When I tried to serialize the RBTree I got an error: "An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll Additional information: The type System.Threading.ReaderWriterLock in Assembly mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as serializable." So this type is not marked as serializable. I there for marked it as "NonSerialized" in my RBTree class, and then I could serialize the RBTree. However, when I try to use the DeSerialized RBTree I get this error: "An unhandled exception of type 'System.NullReferenceException' occurred in Unreal Classes.exe Additional information: Object reference not set to an instance of an object." This error ocurs when the data member of type ReaderWriterLock is referenced. Obviously since it was not reconstructed together with the rest of the RBTree. Any ideas please?

Answers (3)