title: "Object reference not set to an instance of an object" in binary deserializing
body: <p>I am Serializing a class object and storing in sqlite database as BLOB from a C# application.</p>
  
  <p>Function used for serializing: <code>public static byte[] ObjectToByteArray (AnalyzeSubstring obj)</code></p>
  
  <p>And on other application, fetching the blob database and converting blob database in to the object by deserializing. 
  function for deserializing is :<code>public static AnalyzeSubstring ByteArrayToObject (byte[] arrBytes)
  </code></p>
  
  <pre><code>public static byte[] ObjectToByteArray (AnalyzeSubstring obj)
                {
                if ( obj == null )
                    return null;
                BinaryFormatter bf = new BinaryFormatter ();
                //bf.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
                MemoryStream ms = new MemoryStream ();
                bf.Serialize (ms, obj);
                return ms.ToArray ();
                }
  
            public static AnalyzeSubstring ByteArrayToObject (byte[] arrBytes)
                {
                MemoryStream memStream = new MemoryStream ();
                BinaryFormatter binForm = new BinaryFormatter ();
                memStream.Write (arrBytes, 0, arrBytes.Length);
                memStream.Seek (0, SeekOrigin.Begin);
                AnalyzeSubstring obj = (AnalyzeSubstring) binForm.Deserialize (memStream);
                return obj;
                }
  </code></pre>
  
  <p>Issue:In line while deserializing <code>AnalyzeSubstring obj = (AnalyzeSubstring) binForm.Deserialize (memStream);</code>. </p>
  
  <p>It fails with error </p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object .</p>
  </blockquote>
  
  <p>However if we do both operation in same application only, then this work properly.</p>
  
  <p>Please help</p>