G
Guest
Hi,
I would like to serialize an instance of the bitmap instance. Actually, I've
done serialization with the code below, but why parameter Tag is not
serialized? I get the following exception after deserialization: Object
reference is not set to an instance of an object.
// Instance of bitmap.
Bitmap B = new Bitmap(100, 100);
// Add additional property to the bitmap.
B.Tag = 100;
// Serialize.
FileStream fs = new FileStream("test.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, B);
fs.Close();
// Deserialize.
FileStream fs2 = new FileStream("test.dat", FileMode.Open);
BinaryFormatter bf2 = new BinaryFormatter();
Bitmap B2 = (Bitmap)bf2.Deserialize(fs2);
fs2.Close();
int tag = (int)B2.Tag;
All I want is to add the additional property to the bitmap instance, which
must be serialized. Is there any other way to do that?
Thank you.
Regards
Saso
I would like to serialize an instance of the bitmap instance. Actually, I've
done serialization with the code below, but why parameter Tag is not
serialized? I get the following exception after deserialization: Object
reference is not set to an instance of an object.
// Instance of bitmap.
Bitmap B = new Bitmap(100, 100);
// Add additional property to the bitmap.
B.Tag = 100;
// Serialize.
FileStream fs = new FileStream("test.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, B);
fs.Close();
// Deserialize.
FileStream fs2 = new FileStream("test.dat", FileMode.Open);
BinaryFormatter bf2 = new BinaryFormatter();
Bitmap B2 = (Bitmap)bf2.Deserialize(fs2);
fs2.Close();
int tag = (int)B2.Tag;
All I want is to add the additional property to the bitmap instance, which
must be serialized. Is there any other way to do that?
Thank you.
Regards
Saso