Results 1 to 5 of 5

Thread: why is the graphics pen object is not serializable ??? anyone knows why ?

  1. #1

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    why is the graphics pen object is not serializable ??? anyone knows why ?

    Dear all,
    i have been using binary serialzer to serialize some graphics objects and images into one file so that i can save and load them later into use inside my simple software.

    all images, fonts , color variables inside my class (which is declared as <serializable> by the way ) is serialized successfully. when i add a pen object to the class i get an error ?

    here is the error

    -----------------------------------------------------------------------
    System.Runtime.Serialization.SerializationException: The type System.Drawing.Pen in Assembly System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not marked as serializable.
    at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type, Boolean excludeNonSerializable)
    at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
    at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
    at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers)
    at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
    at SoftexTravelControl.FrmHotelFlyers.Button14_Click(Object sender, EventArgs e) in E:\travelmdl.mdl
    ------------------------------------------------------------------------

    what is this error ??

    thank you in advance

    rgds

    Maged A. Reda

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: why is the graphics pen object is not serializable ??? anyone knows why ?

    The type System.Drawing.Pen ... is not marked as serializable.
    To be serialisable a type must be decorated with the Serializable attribute.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: why is the graphics pen object is not serializable ??? anyone knows why ?

    yes i have read the error. and i understand it of course

    i am asking if the pen type is always unserilizable and if there is anything that i can do about to include it in my serialization process.

    please note that i am talking the pen type and not my class, my class is marked as <serializable> and it accepts serialization when it doesnt contain a pen variable

    is there anything that i can do to work around this issue.

    also i remarked in the error this :
    The type System.Drawing.Pen in Assembly System.Drawing, Version=1.0.5000.0,

    is there any other versions of framework that are serializable ???

    thx for your time jmcilhinney

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: why is the graphics pen object is not serializable ??? anyone knows why ?

    It appears that several graphics objects are nonserialisable.

    However, you can always use GDI+'s metafile support to store complex vector graphics. see MSDN.
    I don't live here any more.

  5. #5

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: why is the graphics pen object is not serializable ??? anyone knows why ?

    why cant i inherits from the pen class and mark my new class type as serializable ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width