Search Unity

Anyone else experiencing issues with C# Stream code after 5.6.1?

Discussion in 'Editor & General Support' started by Alturis2, May 18, 2017.

  1. Alturis2

    Alturis2

    Joined:
    Dec 4, 2013
    Posts:
    38
    I just installed 5.6.1 and opened up the project and ran some initial tests and everything seemed to be fine. Then I noticed that my save files were not loading correctly. After some debugging, I am seeing that it appears when I am reading memory from a MemoryStream it is coming back zeroes. I have not changed any of my serialization code so something is amiss here.

    Wondering if anyone else has experienced anything similar to this yet?

    Going to do some more investigation but wanted to touch base here ASAP as this brings my project to a screeching halt.
     
  2. Alturis2

    Alturis2

    Joined:
    Dec 4, 2013
    Posts:
    38
    I confirmed that if I uninstall Unity 5.6.1 and re-install 5.6.0 my serialization works once again. :|

    Something is amiss.
     
  3. Nickromancer

    Nickromancer

    Joined:
    Jul 31, 2016
    Posts:
    92
    Another guy said string interpolation doesn't work in 5.6.1.
    Would that be you are using string.Format() to compose the file path so failed to open the file?

    I myself still using 5.6.0 so I couldn't confirm it.
     
  4. Alturis2

    Alturis2

    Joined:
    Dec 4, 2013
    Posts:
    38
    I resolved my issue finally. In case anyone else runs into this I wanted to post my solve:

    Turns out the real issue was that I was relying on GZipStream and MemoryStream Flush() to finish processing the stream and compress the results or finalize the state of the data. Then I would reset the stream position to 0. But really needed to fully Close() the stream and use ToArray() to access the results.

    For some reason the Flush() worked in 5.6.0 but not in 5.6.1 - something must have changed but as with many things working with C# it is a bit of a black box sometimes.

    [edit] grammar