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. Visual Basic
  4. How to serialize shared members of a class?

How to serialize shared members of a class?

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
2 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    MohammadAmiry
    wrote on last edited by
    #1

    I want to binary serialize a class, which has only shared items (variables & objects of different types) which I use globally in my code. When I want to serialize it, I get the error "'EmailAccount' is a type and cannot be used as an expression" : binformatter.Serialize(filstream, EmailAccount) I even tried to create an object from the class and serialize it. But it seems to only save the instance variables and not the shared ones. Is there a way to serialize them?

    D 1 Reply Last reply
    0
    • M MohammadAmiry

      I want to binary serialize a class, which has only shared items (variables & objects of different types) which I use globally in my code. When I want to serialize it, I get the error "'EmailAccount' is a type and cannot be used as an expression" : binformatter.Serialize(filstream, EmailAccount) I even tried to create an object from the class and serialize it. But it seems to only save the instance variables and not the shared ones. Is there a way to serialize them?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Serialzation only works on instance members. Shared, or static in C#, members are not part of any instance. You'll have to either save them sepearately or there are various methods of including the static members in the serialization, but they will be included in every single instance of the class you serialize. One method would be to create public "wrapper" properties for the shared members.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      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