title: Why does MemoryStream.GetBuffer() always throw?
body: <p>The following code will always throw 
  UnuthorizedAccessException  (MemoryStream's internal buffer cannot be accessed.)</p>
  
  <pre><code>byte[] buf1 = { 2, 3, 5, 7, 11 };
  var ms = new MemoryStream(buf1);
  byte[] buf2 = ms.GetBuffer();      // exception will be thrown here
  </code></pre>
  
  <p>This is in a plain old console app and I'm running as an admin. I can't imagine a more privileged setting I could give this code. So why can't I get at this buffer? (And if nobody can, what's the point of the GetBuffer method?) </p>
  
  <p>The MSDN docs say  </p>
  
  <blockquote>
    <p>To create a MemoryStream instance with
    a publicly visible buffer, use
    MemoryStream,
    MemoryStream(array[], Int32,
    Int32, Boolean, Boolean), or
    MemoryStream(Int32).</p>
  </blockquote>
  
  <p>Am I not doing that?</p>
  
  <p>P.S.  I don't want to use ToArray() because that makes a copy.</p>