How do I prevent a BinaryFormatter Deserialize method from hanging?

52 Views Asked by At

The code below hangs on the last statement. I have no idea what to look for to fix.

string tstName = "c:\\tmp\\tmp.tst";
BinaryWriter out = new BinaryWriter(File.OpenWrite(tstName)); 
BinaryFormatter outformatter = new BinaryFormatter();
outformatter.Serialize(out.BaseStream, myClass);
out.Close();

BinaryReader inn = new BinaryReader(File.OpenRead(tstName));
BinaryFormatter informatter = new BinaryFormatter();
MyClass pTest = 
    (MyClass)informatter.Deserialize(inn.BaseStream);

If it is of any help, the file 'tmp.tst' contains 148 MB after the serialization.

0

There are 0 best solutions below