gpt4 book ai didi

c# - 什么可能导致本地 WCF 命名管道出现 EndpointNotFoundException?

转载 作者:行者123 更新时间:2023-11-30 22:18:34 24 4
gpt4 key购买 nike

我已经设置了一个系统来让工作进程做一些工作,并在 GUI 进程和工作进程之间协调命名管道。我在这里启动工作进程:

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();

然后在worker进程里面:

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();

对于大多数人(包括我)来说,它在 100% 的时间里都能正常工作。但是一位用户报告说,当尝试连接到工作进程时,主机进程总是得到一个 EndpointNotFoundException,即使有一个日志表明 GUID 在两边是相同的并且状态是打开的工作进程。

我想一定是他的系统有什么不同导致了故障,我想知道那可能是什么。

  • 我试过通过远程桌面连接,但对我来说仍然有效。
  • 我没有更改任何一个过程的强制完整性级别
  • 我读了this answer所以我要求用户运行 net localgroup "NETWORK USERS" 但该组对他来说不存在
  • (编辑)Net.Pipe Listener Adapter 服务已为用户禁用,但在用户启用并启动后它仍然无法工作。

关于为什么会发生这种情况,还有其他想法吗?我阅读了一些关于本地和全局命名管道的内容,但由于我在本地进行通信并在本地生成进程,所以这似乎不是问题。

(edit2) 用户意外地能够获得 WCF 跟踪:http://engy.us/misc/TracesWithNetPipeStarted.svclog

(edit3) 它显然在以管理员身份运行主机进程时有效。在这种情况下,管道通信的某些部分是否需要这些特权?如何设置管道 channel ,使其永远不需要管理员?

最佳答案

看看this SOA question and answer ,其中详细解释了如果不小心选择了后者的服务 URL,则特定 session 本地的 WCF NetNamedPipeBinding 服务如何可能被全局发布的不相关应用程序阻止。

对于您所描述的情况,这似乎是一个合理的解释。

关于c# - 什么可能导致本地 WCF 命名管道出现 EndpointNotFoundException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16020706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com