SerializationException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sapsy

    #1

    SerializationException

    hi,
    I have a class which uses Microsoft.Win32 .RegistryKey
    class, and i am trying to Serialize this class but i get the following
    Error... anu ponter will be really helpfull..

    Message="Type 'Microsoft.Win3 2.RegistryKey' in Assembly 'mscorlib,
    Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' is
    not marked as serializable."



    Thanks
    Rohit Sapru

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: SerializationEx ception

    Rohit,

    Well, the exception is obvious. The RegistryKey class is not meant to
    be serialized.

    You will have to tag the field with the NonSerialized attribute, and
    then make sure your class will be able to load the information it needs into
    that field so that it works correctly when deserialized.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "sapsy" <Rsapru@gmail.c omwrote in message
    news:1180459774 .643819.307540@ k79g2000hse.goo glegroups.com.. .
    hi,
    I have a class which uses Microsoft.Win32 .RegistryKey
    class, and i am trying to Serialize this class but i get the following
    Error... anu ponter will be really helpfull..
    >
    Message="Type 'Microsoft.Win3 2.RegistryKey' in Assembly 'mscorlib,
    Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' is
    not marked as serializable."
    >
    >
    >
    Thanks
    Rohit Sapru
    >

    Comment

    • Jorge

      #3
      Re: SerializationEx ception

      On May 29, 2:29 pm, sapsy <Rsa...@gmail.c omwrote:
      hi,
      I have a class which uses Microsoft.Win32 .RegistryKey
      class, and i am trying to Serialize this class but i get the following
      Error... anu ponter will be really helpfull..
      >
      Message="Type 'Microsoft.Win3 2.RegistryKey' in Assembly 'mscorlib,
      Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' is
      not marked as serializable."
      >
      Thanks
      Rohit Sapru

      Try to find all references to this type in the object graph and mark
      it with the nonserializable attribute.
      If you need to serialize this type, you might implement the
      ISerializable in the parent object to customize this member
      serialization.

      Comment

      • sapsy

        #4
        Re: SerializationEx ception

        Hi,
        I just moved my registry declaration from global to method
        level and it worked .....

        Thanks

        Comment

        Working...