Object reference not set to an instance of an object

Issue #2 wontfix
Robert Važan repo owner created an issue

Originally submitted by MalteB.

I am trying to save a stringified JSON object to disk and run into the following error:

Object reference not set to an instance of an object.
  + Snappy.SnappyStream.Dispose(bool)
  + System.IO.Stream.Close()
  + System.IO.Stream.Dispose()
  + [...].toSnappyJson(string)

this is my code (pretty much copied from the website)

using Snappy;
using Newtonsoft.Json;
...

        public void toSnappyJson(string path)
        {
            using (var file = File.OpenWrite(path))
            using (var snap = new SnappyStream(file, System.IO.Compression.CompressionMode.Compress))
            using (var writer = new StreamWriter(snap))
            {
                var res = JsonConvert.SerializeObject(this);
                writer.WriteLine(res);
            }
        }

Comments (1)

  1. Log in to comment