The first thing I'd try changing is here:
do
{
// !!! problematic function call here !!!
int BytesRead = NPSS.Read(PipeDataBuffer, 0, PipeDataBuffer.Length);
// !!!
MessageStream.Write(PipeDataBuffer, 0, BytesRead);
TotalBytesRead += BytesRead;
} while (!NPSS.IsMessageComplete);
It doesn't check that BytesRead
is +ve; now I would expect MessageStream.Write
to explode if it was negative, but... either way; I would definitely check for an unexpected <=0
condition there.
Marc Gravell
2010-06-18 19:52:38