gpt4 book ai didi

.net-core - 如何在 .NET Core 中设置 NamedPipeServerStream 的 PipeSecurity

转载 作者:行者123 更新时间:2023-12-04 13:39:02 25 4
gpt4 key购买 nike

我正在将一个库从 .NET Framework 4.6.1 移植到 .NET Standard 2.0。在框架中,NamedPipeServerStream构造函数可以采用 PipeSecurity参数,但这不是 Core 中的一个选项。你如何设置 NamedPipeServerStream 的安全性在核心?

最佳答案

显然这是一个已知问题
System.IO.Pipes.AccessControl package does not work #26869 .上一篇文章中提到了一个解决方法,建议使用 NamedPipeServerStream.NetFrameworkVersion nuget 包将暴露 NamedPipeServerStreamConstructors.New(...)这应该反射(reflect)所有完整的 .NET Framework 构造函数的行为。

遵循来自 nuget 的 github 的代码示例

using System.IO.Pipes;

var pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));

using var serverStream = NamedPipeServerStreamConstructors.New(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous | PipeOptions.WriteThrough, 0, 0, pipeSecurity);

关于.net-core - 如何在 .NET Core 中设置 NamedPipeServerStream 的 PipeSecurity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59969943/

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