System.IO.Pipes.NamedPipeServerStream class throws IOException and the documentation says The maximum number of server instances has been exceeded. This message is not very clear to me. Can someone explain it in terms of I can understand? Does it mean that the same code is being executed by two different processes or something like that? How can I avoid it if it happens rarely?
I am using the following constructor:
int maxNumberServerInstance = 1;
new NamedPipeServerStream(name, PipeDirection.InOut, maxNumberServerInstance , PipeTransmissionMode.Message, PipeOptions.None, bufferSize, bufferSize, pipeSecurity);
I get IOException.
Let's visit the documentation.
NamedPipeServerStream Class
NamedPipeServerStream.MaxAllowedServerInstances Field
In short the error is telling you that the maximum amount of instances has been created.
You will get this if you have used the default constructor with just the name, additionally you will get a pipe with the following characteristics:
At minimum you would want to use the following constructor if you need more than one instance:
NamedPipeServerStream(String, PipeDirection, Int32)
Lastly, if you are getting this error and you have only one instance, you probably have a subtle problem with how you are creating them.