【问题标题】:System.UnauthorizedAccessException is thrown from console app started from w3wp when AnonymousPipeServerStream used当使用 AnonymousPipeServerStream 时,从 w3wp 启动的控制台应用程序抛出 System.UnauthorizedAccessException
【发布时间】:2017-02-22 21:57:58
【问题描述】:

我有一个控制台应用程序,我从 w3wp 作为进程启动。应用程序应使用网站文件夹下的文件进行操作。一切正常,直到我决定使用 AnonymousPipeServerStream 与控制台应用程序通信(我想从控制台应用程序接收消息)。

        var pipeServer = new AnonymousPipeServerStream(PipeDirection.In);
        var pipeStreamReader = new StreamReader(pipeServer);

        ProcessStartInfo si = new ProcessStartInfo(fileName);
        si.Arguments = $"{pipeServer.GetClientHandleAsString()} {arguments}";
        si.CreateNoWindow = true;
        si.UseShellExecute = false;
        si.RedirectStandardError = true;
        si.RedirectStandardOutput = true;

添加此代码后,控制台应用程序开始崩溃并出现异常

System.UnauthorizedAccessException:对路径 'C:\inetpub\wwwroot\... 的访问被拒绝。

抛出异常的代码:

File.Open(this.Path, FileMode.CreateNew);

如果我用 AnonymousPipeServerStream 注释掉代码,一切都会按预期工作。

AnonymousPipeServerStream 是否可能更改控制台应用程序启动的主体或任何可能导致此类行为的想法?

【问题讨论】:

  • 哪条指令抛出异常(调用堆栈)?
  • 我尝试使用 File.Open(this.Path, FileMode.CreateNew); 在那里创建文件;

标签: c# w3wp


【解决方案1】:

这似乎是代码未连接管道中的错误。抱歉打扰了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-30
    • 1970-01-01
    • 2017-05-21
    • 2022-01-14
    • 1970-01-01
    相关资源
    最近更新 更多