Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to Serialize System.Drawing.Pen

Reply
Thread Tools

How to Serialize System.Drawing.Pen

 
 
Sergio Dinis
Guest
Posts: n/a
 
      10-02-2003
Hi All.
Anybody know how can I serialize an instance of System.Drawing.Pen?
I already have an idea but can't work. It consists of creating a new class
witch derives from Pen, but Pen is sealed. The only way I know is to create
a new class witch implements System.Runtime.Serialization.ISerialize that
has a Pen.

Thanks.


 
Reply With Quote
 
 
 
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      10-03-2003
Sergio,
> Anybody know how can I serialize an instance of System.Drawing.Pen?

You can't as it does not have the Serializable attribute attached.

I would consider defining a Serialization Surrogate for it, define a class
that implements the System.Runtime.Serialization.ISerializationSurroga te
interface.

A Serialization Surrogate is a helper class that knows how to read the
values of the Pen and save them in the serialization stream, it also knows
how to deserialize the values and create a Pen again.

Part 3 of the following 3 part MSDN Magazine articles covers
ISerializationSurrogate along with caveats on its use.

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

The example is in C#, however its straight forward enough it should be
easily converted into VB.NET.

Hope this helps
Jay


"Sergio Dinis" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All.
> Anybody know how can I serialize an instance of System.Drawing.Pen?
> I already have an idea but can't work. It consists of creating a new class
> witch derives from Pen, but Pen is sealed. The only way I know is to

create
> a new class witch implements System.Runtime.Serialization.ISerialize that
> has a Pen.
>
> Thanks.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Mike Larkin ASP .Net 1 05-23-2005 12:33 PM
serialize to SQL Server Blob instead of XML serialize Gordz ASP .Net 3 06-07-2004 07:46 PM
How to Serialize DataTable Drew ASP .Net 0 12-11-2003 06:57 PM
Serialize Object in Session? nick ASP .Net 2 08-21-2003 08:14 PM
Can I make a class from XML? Serialize? Jonah Olsson ASP .Net 12 08-09-2003 04:18 PM



Advertisments