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 2 1515
Saso,
In Bitmap basclass Tag might have been marked as non serialiable. What
you can do , Create your own bitmap class derived from Bitmap and override
Tag property or create your own property to store your variable. Dont forget
to mark your class with [Serializable()] attribute.
Thanks
Baski
"Saso" <Sa**@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
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
Baski,
I already tryed to derive from bitmap class, but unfortunately it can not be
derived from sealed type such System.Drawing.Bitmap is. Any suggestion?
Regards.
Saso
"Baski" wrote:
Saso,
In Bitmap basclass Tag might have been marked as non serialiable. What
you can do , Create your own bitmap class derived from Bitmap and override
Tag property or create your own property to store your variable. Dont forget
to mark your class with [Serializable()] attribute.
Thanks
Baski
"Saso" <Sa**@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David K |
last post by:
we are having a problem when trying to serilalize and deserialize DataTable
When replacing the container to be ListArray or HashTable everything works
fine
The code is very straight forward (...
|
by: Ben |
last post by:
Hi, there.
Recently I was working on a problem where we want to save generic
closures in a data structure (a vector). The closure should work for
any data type and any method with pre-defined...
|
by: ktn |
last post by:
Hi all,
I'm a .NET beginner and I've got a problem on a program where I try to do an
XML serialization.
I get the following error :
"An unmanaged exception of type...
|
by: andrewcw |
last post by:
There is an error in XML document (1, 2).
I used XML spy to create the XML and XSD. When I asked to
have the XML validated it said it was OK.
I used the .net SDK to generate the class. I have...
|
by: ofer |
last post by:
Hi,
I am working with the beta version of the new .net framework (Whidbey) and I
encountered a problem with serialization that did'nt exist in the .net 2003
the situation is like this :
I have...
|
by: umhlali |
last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem...
|
by: Harold Howe |
last post by:
I am having a problem deserializing objects from a library when the
following conditions exist:
1- The library is strongly named
2- The serialized file was created with version 1.0 of the...
|
by: Norman Chong |
last post by:
Hiddeldi ho,
I want to save an object so that I can use its content after I restart
my program. I tried to solve this with serialization because someone
told me that this is the correct way for...
|
by: mijalko |
last post by:
Hi,
I have inherited my class from System.Drawing.Printing.PrintDocument
and I wish to serialize this object using XmlSerializer. And I get
exception "There was an error reflecting type ...". If I...
|
by: mkvenkit.vc |
last post by:
Hello,
I hope this is the right place to post a question on Boost. If not,
please let me know where I can post this message and I will do so.
I am having a strange problem with std::string as...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |