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
J

jmlstele

@jmlstele
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Serialization Issue with Int32
    J jmlstele

    Yes, while I agree that that does work, what I really want to know is WHY cant I use Int32^ when things like String^ work just fine. I think there should be some documentation somehwere that says "You can't serialize certain references.. " somewhere. Myabe there already is, but i can't find it.

    Managed C++/CLI data-structures json help question announcement

  • Serialization Issue with Int32
    J jmlstele

    While I'm posting possible problems I've found... When a struct (or class for that matter) with an Int32 ^ is deserialized an exception is thrown. Again: Is this a "feature" that I just haven't seen documented anywhere, or an actual issue? ----CODE---- using namespace System; using namespace System::IO; using namespace System::Runtime::Serialization::Formatters::Binary; [Serializable] public ref struct TestStruct { Int32^ i; }; [Serializable] public ref struct TestStruct2 { int i; }; int main(array ^args) { //MemoryStream to do use for serializing MemoryStream^ ms = gcnew MemoryStream(); //Binary Format BinaryFormatter^ bf = gcnew BinaryFormatter(); //Create the structure TestStruct ^t = gcnew TestStruct(); //Initialize the data t->i = 42; //Serialize the string bf->Serialize(ms,t); //GO back to the beginning of the stream to deserialize ms->Seek(0,SeekOrigin::Begin); try { Object^ o = bf->Deserialize(ms); System::Console::WriteLine("o is {0}",o); } catch(System::Runtime::Serialization::SerializationException^ e) { System::Console::WriteLine("Caught an exception while trying to deserialize TestStruct!"); System::Console::WriteLine(e->Message); } /* Generates Exception: Type: System.Runtime.Serialization.SerializationException Additional information: Binary stream '42' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization. Note the 42. If t->i is set to a different value, this changes. */ //Reset for second test ms = gcnew MemoryStream(); bf = gcnew BinaryFormatter(); TestStruct2 ^t2 = gcnew TestStruct2(); t2->i = 42; bf->Serialize(ms,t2); ms->Seek(0,SeekOrigin::Begin); try { Object^ o = bf->Deserialize(ms); System::Console::WriteLine("o is {0}",o); } catch(System::Runtime::Serialization::SerializationException^ e) { System::Console::WriteLine("Caught an exception while trying to deserialize TestStruct2!"); System::Console::WriteLine(e->Message); } /* No Exception Generated */ return 0; } ----CODE END----

    Managed C++/CLI data-structures json help question announcement

  • Undocumented problem with for each
    J jmlstele

    Just in case my message about what fixes it wasn't clear: Bad: ----CODE---- if (false) for each (int i in test) { Console::Write("for each "); Console::WriteLine(i); } ----CODE END---- Good: ----CODE---- if (false) { for each (int i in test) { Console::Write("for each "); Console::WriteLine(i); } } ----CODE END---- But yeah... Original question still stands: Is this a "feature" or a genuine bug?

    Managed C++/CLI data-structures help learning
  • Login

  • Don't have an account? Register

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