title: Cannot connect to named pipe
body: <p>i am trying to communicate between native application and managed application, i am using NamedPipe. i have tried first with c++ to create and open namedpipe how ever i am getting error of security</p>
  
  <pre><code>SECURITY_ATTRIBUTES sa;
  sa.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
  if (!InitializeSecurityDescriptor(sa.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
  {
      DWORD er = ::GetLastError();
  }
  if (!SetSecurityDescriptorDacl(sa.lpSecurityDescriptor, TRUE, (PACL)0, FALSE))
  {
      DWORD er = ::GetLastError();
  }
  sa.nLength = sizeof sa;
  sa.bInheritHandle = TRUE;
  // To know the maximal size of the received data for reading from the      // pipe buffer
  
  union maxSize
  {
      UINT   _1;
  };
  
  _pipe = ::CreateNamedPipe(pipeName.c_str(), PIPE_ACCESS_INBOUND, 
                              PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 
                              PIPE_UNLIMITED_INSTANCES, 
                              sizeof maxSize, 
                              sizeof maxSize,
                              NMPWAIT_USE_DEFAULT_WAIT,
                              &amp;sa);
  
  if (_pipe == INVALID_HANDLE_VALUE)
  {
      DWORD dwError = ::GetLastError();
  }
  
  cout&lt;&lt;"Connected to Pipe"&lt;&lt;endl;
  
  auto pipe = CreateFile( 
       pipeName.c_str(),   // pipe name 
       GENERIC_READ | GENERIC_WRITE ,  // read and write access 
       0,              // no sharing 
       &amp;sa,           // default security attributes
       OPEN_EXISTING,  // opens existing pipe 
       0,              // default attributes 
       NULL);          // no template file 
  
  
  if (pipe == INVALID_HANDLE_VALUE)
  {
      DWORD dwError = ::GetLastError();
      cout&lt;&lt;"Failed to open Pipe "&lt;&lt;dwError&lt;&lt;endl;
  }
  </code></pre>