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. Managed C++/CLI
  4. Serialize with BinaryFormatter

Serialize with BinaryFormatter

Scheduled Pinned Locked Moved Managed C++/CLI
data-structureshelp
1 Posts 1 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.
  • H Offline
    H Offline
    hansipet
    wrote on last edited by
    #1

    Hello, I have a strange problem. I want to send some objectes over Ethernet (UDP One packet is one object) After that I Deserialize the data, but I get allways an exception that there is an Invalid binaryheader. I don't have any idea how I can solve it. my code is int size = socket.Receive(buf); BinaryFormatter serializer; MemoryStream^ ms = gcnew MemoryStream(buf,0,size); ms->Seek(0, SeekOrigin::Begin); LogMessage^ logMessage = (LogMessage^)serializer.Deserialize(ms); Console::WriteLine("{0}", logMessage->ToString()); ms->Close(); and the sending function: MemoryStream^ ms = gcnew MemoryStream(); //XmlSerializer serializer(LogMessage::typeid); BinaryFormatter serializer; serializer.Serialize(ms, logMessage); ms->Flush(); ms->Seek(0, SeekOrigin::Begin); array^ data = ms->ToArray(); socket->Send(data); ms->Close(); I have checked the MemoryStream and there is the whole data available (Sending and receiving) Best regards Hansjörg

    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