title: CallNamedPipe & NamedPipeServerStream, access denied?
body: <p>I'm trying to do some IPC between a managed and unmanaged process.  I've settled on named pipes.</p>
  
  <p>I'm spinning up a thread in managed code, using <a href="http://msdn.microsoft.com/en-us/library/system.io.pipes.namedpipeserverstream.aspx" rel="nofollow noreferrer">NamedPipeServerStream</a>:</p>
  
  <pre><code>using (NamedPipeServerStream stream = new NamedPipeServerStream("MyPipe", PipeDirection.In))
  {
    while (true)
    {
      stream.WaitForConnection();
      stream.Read(buffer, 0, size);
      //Handle buffer values
    }
  }
  </code></pre>
  
  <p>On the unmanaged side I'm using <a href="http://msdn.microsoft.com/en-us/library/aa365144(VS.85).aspx" rel="nofollow noreferrer">CallNamedPipe</a>:</p>
  
  <pre><code>CallNamedPipe(TEXT("\\\\.\\pipe\\MyPipe"), NULL, 0, pData, dataSize, NULL, NMPWAIT_WAIT_FOREVER);
  </code></pre>
  
  <p>However, CallNamedPipe fails with a GetLastError of 5 (Access Denied).  Any idea why?</p>