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. Serialize

Serialize

Scheduled Pinned Locked Moved C#
jsonhelp
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
    andreas_farnstrand
    wrote on last edited by
    #1

    Hi! I'm trying to open a file with a serialized (binary) arraylist. The problem is that the application in which I save the data saves the assemblyname in the file, so when I try to open the file in another application whith another name, it throws an exception. System.Runtime.Serialization.SerializationException. There's probably an easy way to solve this but I'm rather new at this so... Thanx Andreas Färnstrand

    J D 2 Replies Last reply
    0
    • A andreas_farnstrand

      Hi! I'm trying to open a file with a serialized (binary) arraylist. The problem is that the application in which I save the data saves the assemblyname in the file, so when I try to open the file in another application whith another name, it throws an exception. System.Runtime.Serialization.SerializationException. There's probably an easy way to solve this but I'm rather new at this so... Thanx Andreas Färnstrand

      J Offline
      J Offline
      jtmtv18
      wrote on last edited by
      #2

      throw in some of your code you used to save the serialized arraylist. i have my serialize class wrote with this code.. among others. this will fill the memorystream and return its byte[] MemoryStream memstr = new MemoryStream(); BinaryFormatter formatter =new BinaryFormatter(); formatter.Serialize(memstr,MyObjectHere); return memstr.ToArray(); to save it i call this. Stream fs= File.Create(path); byte[] tmp = \*(The Byte Array From Above here)*\ memstr.ToArray(); fs.Write(tmp,0,tmp.Length); //the serialized object is wrote now. to open it stream= File.Open(path,FileMode.Open); // BinaryFormatter bf = new BinaryFormatter(); Object =(CastingObjectHere)bf.Deserialize(stream); hope this helps, if not. someone older and wiser will help u =) The Code Project Is Your Friend...

      1 Reply Last reply
      0
      • A andreas_farnstrand

        Hi! I'm trying to open a file with a serialized (binary) arraylist. The problem is that the application in which I save the data saves the assemblyname in the file, so when I try to open the file in another application whith another name, it throws an exception. System.Runtime.Serialization.SerializationException. There's probably an easy way to solve this but I'm rather new at this so... Thanx Andreas Färnstrand

        D Offline
        D Offline
        Daniel Turini
        wrote on last edited by
        #3

        What you need is a SerializationBinder for the new assembly. See the sample code on MSDN for System.Runtime.Serialization.SerializationBinder for something similar to what you want... Yes, even I am blogging now!

        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