I've got a system set up to let a worker process do some job and am coordinating with named pipes between the GUI process and the worker process. I kick off the worker process here:
this.pipeGuidString = Guid.NewGuid().ToString();
var startInfo = new ProcessStartInfo(
"VidCoderWorker.exe",
Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture) + " " + this.pipeGuidString);
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
this.worker = Process.Start(startInfo);
// When the process writes out a line, its pipe server is ready and can be contacted for
// work. Reading line blocks until this happens.
this.logger.Log("Worker ready: " + this.worker.StandardOutput.ReadLine());
bool connectionSucceeded = false;
this.logger.Log("Connecting to process " + this.worker.Id + " on pipe " + this.pipeGuidString);
var binding = new NetNamedPipeBinding
{
OpenTimeout = TimeSpan.FromSeconds(10),
CloseTimeout = TimeSpan.FromSeconds(10),
SendTimeout = TimeSpan.FromSeconds(10),
ReceiveTimeout = TimeSpan.FromSeconds(10)
};
this.pipeFactory = new DuplexChannelFactory<IHandBrakeEncoder>(
this,
binding,
new EndpointAddress("net.pipe://localhost/" + pipeGuid + "/VidCoder"));
this.channel = this.pipeFactory.CreateChannel();
this.channel.Ping();
Then inside the worker process:
host = new ServiceHost(
typeof (HandBrakeEncoder),
new Uri[]
{
new Uri("net.pipe://localhost/" + PipeGuidString)
});
host.AddServiceEndpoint(
typeof (IHandBrakeEncoder),
new NetNamedPipeBinding(),
"VidCoder");
host.Open();
encodeComplete = new ManualResetEventSlim(false);
Console.WriteLine("Service state is " + host.State + " on pipe " + PipeGuidString);
encodeComplete.Wait();
host.Close();
It works fine for most people (including me) 100% of the time. But one user reports that the host process always gets an EndpointNotFoundException when trying to connect to the worker process, even with a log that indicates that the GUID was the same on both sides and the state was Opened on the worker process.
I figure that he must have something different with his system that's causing the failure and am wondering what that could be.
- I've tried connecting via Remote Desktop and that still works for me.
- I have not changed the Mandatory Integrity level on either process
- I read this answer so I asked the user to run
net localgroup "NETWORK USERS"
but the group does not exist for him - (edit) Net.Pipe Listener Adapter service was disabled for the user but it still did not work after the user enabled and started it.
Any other ideas about why this would be happening? I read some stuff about local vs global named pipes but since I'm communicating locally and spawning the process locally it didn't seem like it should be an issue.
(edit2) User was surprisingly able to get a WCF trace: http://engy.us/misc/TracesWithNetPipeStarted.svclog
(edit3) It apparently works when running the host process as Administrator. Could it be that in this case some part of the pipe communication was requiring those privileges? How can I set up the pipe channel so that it never needs admin?