【发布时间】:2021-04-03 10:38:28
【问题描述】:
我正在尝试使用 NamedPipeServerStream 与另一个进程接收和发送消息。我正在开发的平台是 UWP(Microsoft.NETCore.UniversalWindowsPlatform 版本 6.2.11)。
我的第一次尝试如下:
using (NamedPipeServerStream pipe = new NamedPipeServerStream(
"DynamicCabPipe",
PipeDirection.InOut,
10,
PipeTransmissionMode.Byte,
PipeOptions.Asynchronous,
32,
32)) {...}
结果
System.UnauthorizedAccessException: 'Access to the path is denied'
经过一番研究,我找到了这个解决方案:How to set PipeSecurity of NamedPipeServerStream in .NET Core
var pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite, AccessControlType.Allow));
using (NamedPipeServerStream pipe = NamedPipeServerStreamConstructors.New(
"DynamicCabPipe",
PipeDirection.InOut,
10,
PipeTransmissionMode.Byte,
PipeOptions.Asynchronous,
32,
32, pipeSecurity)) { ... }
结果
System.Resources.MissingManifestResourceException: 'Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Core.resources" was correctly embedded or linked into assembly "NamedPipeServerStream.NetFrameworkVersion" at compile time, or that all the satellite assemblies required are loadable and fully signed.'
现在我被困住了。有什么建议吗?
【问题讨论】:
-
管道受制于 UWP 应用的沙盒规则。具体来说,它将始终拒绝在两个进程之间建立管道的尝试。所以“拒绝访问”是预期的结果。
-
嗨vuoriov4,我目前正面临这个问题。对于这个问题,您是否找到了一些可以分享的解决方法,或者您有什么建议可以继续进行?
-
我的“解决方法”是放弃 UWP 和随之而来的沙盒规则。
标签: c# .net named-pipes