title: .Net zlib inflate with .Net 4.5
body: <p>According to MSDN in .Net 4.5 System.IO.Compression is based on zlib.<br>
  I am trying now to change my current interop based reading from a zlib deflated stream from a non .NET server into a BCL based implementation.<br>
  My implementation looks like this:</p>
  
  <pre><code>    var enc = new UTF8Encoding();            
          var readBytes = BufferSizeRaw;
          var outputBuffer = new byte[BufferSizeRaw];            
          var networkBuffer = _networkQueue.Take();
          var ms = new MemoryStream(networkBuffer.InputBuffer, 0, networkBuffer.UsedLength);
          using (Stream stream = new DeflateStream(ms, CompressionMode.Decompress))
              while (readBytes==BufferSizeRaw)
              {
                  readBytes = stream.Read(outputBuffer, 0, outputBuffer.Length);                
                  stringBuffer+= enc.GetString(outputBuffer, 0, readBytes);                
              }
  </code></pre>
  
  <p>I receive the following exception on the first call of the decompression/read on the DeflateStream :</p>
  
  <blockquote>
    <p>Block length does not match with its complement</p>
  </blockquote>
  
  <p>The interop based call uses <code>var result=inflate(ref zStyream, ZLibFlush.NoFlush;</code>
  <br>
  Has anyone tried the same or sees a reason for an error in the code or is there a wrong understanding on my end?
  I have also tried it with truncating the first two bytes without any luck.<br>
  The first few bytes are 20, 202, 177,13.</p>