Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Save/Store non serializable objects

How to Save/Store non serializable objects

Scheduled Pinned Locked Moved C#
sysadminjsonhelptutorialquestion
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anindya Chatterjee
    wrote on last edited by
    #1

    While coding for a MS Exchange email client I came up with a peculiar problem. I am using Exchange Web Service Managed API to access the exchange mail server and getting the mail messages. The problems occur when I try to store the message object into the disk. While serializing the object it is throwing a SerializationException saying that - "Type 'Microsoft.Exchange.WebServices.Data.EmailMessage' in Assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.". One thing is not clear to me, if the object is not serializable then how come it is being transferred through the web service? Secondly, do any one have any idea on how to store this non serializable object into disk. I am in a dire need. Thanks and regards,

    Anindya Chatterjee --------------------------------------------------------

    K B 2 Replies Last reply
    0
    • A Anindya Chatterjee

      While coding for a MS Exchange email client I came up with a peculiar problem. I am using Exchange Web Service Managed API to access the exchange mail server and getting the mail messages. The problems occur when I try to store the message object into the disk. While serializing the object it is throwing a SerializationException saying that - "Type 'Microsoft.Exchange.WebServices.Data.EmailMessage' in Assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.". One thing is not clear to me, if the object is not serializable then how come it is being transferred through the web service? Secondly, do any one have any idea on how to store this non serializable object into disk. I am in a dire need. Thanks and regards,

      Anindya Chatterjee --------------------------------------------------------

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      Anindya Chatterjee wrote:

      One thing is not clear to me, if the object is not serializable then how come it is being transferred through the web service?

      Probably, the EmailMessage isn't the thing being passed across the wire.

      Anindya Chatterjee wrote:

      Secondly, do any one have any idea on how to store this non serializable object into disk.

      Two options (but I don't know the details of EMailMessage, so take with a pinch of salt: a) Make a serializeable object and write a converter to convert bewteen this andEmailMessage b) Hand-serialize the object from its properties etc. That said, the object you have probably contains alot of information needed at runtime and have security implications (which are probably two of the reasons why the object is not marked as serializable). Given there are lots of readonly properties, you won't be able to deserialize EMailMessage, but if you are just interested in storing and retrieving the contents you should be fine.

      Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

      1 Reply Last reply
      0
      • A Anindya Chatterjee

        While coding for a MS Exchange email client I came up with a peculiar problem. I am using Exchange Web Service Managed API to access the exchange mail server and getting the mail messages. The problems occur when I try to store the message object into the disk. While serializing the object it is throwing a SerializationException saying that - "Type 'Microsoft.Exchange.WebServices.Data.EmailMessage' in Assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.". One thing is not clear to me, if the object is not serializable then how come it is being transferred through the web service? Secondly, do any one have any idea on how to store this non serializable object into disk. I am in a dire need. Thanks and regards,

        Anindya Chatterjee --------------------------------------------------------

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        Does that EmailMessage not have a ToString() and a FromString() method? Since emails are transported as plain ASCII, that should do the thing. Otherwise, create a serializable object containing all the relevant properties, i.e. message body, to, cc, subject, etc. and serialize that.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups