XmlSerializer, truncated file?

NicholasBauerNicholasBauer USMember ✭✭

I'm using XmlSerializer to serialize an object to Xml when the app sleeps and then restore it when it resumes. It seems to work fine on Android, but on iOS I'm seeing errors on restore from users, where the file was truncated to 125 characters:

<?xml version="1.0" encoding="utf-8"?> <AppState xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/20

Doesn't seem to happen on my simulator.

Is there a timelimit for OnSleep to complete that could be cutting it off? Or is there something else going on?

My serialization code:

        public async Task SerializeToFileAsync(Stream fileStream)
        {
            using (var ms = new MemoryStream())
            {
                var serializer = new XmlSerializer(typeof(AppState));
                serializer.Serialize(ms, this);
                ms.Position = 0;
                await ms.CopyToAsync(fileStream);
            }
        }

What might be happening, and how can I fix it?

Sign In or Register to comment.