Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure if this will help but I am also experiencing the same problem. First of all, I don't know why any reference to m_pipeServerStream.IsConnected will break the pipe. I tested this with just a simple MessageBox.Show(m_pipeServerStream.IsConnected.ToString()) and that broke my pipe! </p> <p>Secondly, another weird thing is that your streamreader call will never return if you are using a duplex named pipe. You will need to read it manually like this </p> <pre><code> const int BufferSize = 4096; Decoder decoder = Encoding.UTF8.GetDecoder(); StringBuilder msg = new StringBuilder(); char[] chars = new char[BufferSize]; byte[] bytes = new byte[BufferSize]; int numBytes = 0; MessageBox.Show("before do while loop"); numBytes = pipeServer.Read(bytes, 0, BufferSize); if (numBytes &gt; 0) { int numChars = decoder.GetCharCount(bytes, 0, numBytes); decoder.GetChars(bytes, 0, numBytes, chars, 0, false); msg.Append(chars, 0, numChars); } MessageBox.Show(numBytes.ToString() + " " + msg.ToString()); MessageBox.Show("Finished reading, now starting writing"); using (StreamWriter swr = new StreamWriter(pipeServer)) { MessageBox.Show("Sending ok back"); swr.WriteLine("OK"); pipeServer.WaitForPipeDrain(); } </code></pre> <p>Anyway, it doesn't seem to like the behavior of StreamReader, but this will work for now... I got this off this link <a href="http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/23dc2951-8b59-48e4-89fe-d2b435db48c6/" rel="nofollow">http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/23dc2951-8b59-48e4-89fe-d2b435db48c6/</a></p> <p>I'm not following every single step because I just needed to find out why it keeps hanging at StreamReader.ReadLine(). it's not returning from this function. StreamWriter does not seem to have this problem. </p> <p>I am actually communicating between native dll and a managed windows service. Imagine my surprise when I found out that it was the managed part that was the problem, not the unmanaged part since they has such good examples in msdn...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload