在Linux .Net Core的新控制台窗口中打开.dll

时间:2017-12-19 14:12:26

标签: c# .net-core

我可以通过运行:

在同一控制台窗口中运行program.dll
    var process = new Process
    {

        StartInfo = new ProcessStartInfo
        {
            FileName = "dotnet",
            Arguments = "program.dll",
            UseShellExecute = true,
            RedirectStandardOutput = false,
            RedirectStandardError = false,
            CreateNoWindow = false
        }
    };

    process.Start();

标志CreateNoWindow = false不像在Windows系统上那样打开新控制台。

如何使用.NET Core在Linux的新控制台窗口中打开program.dll

我看到this question但它在linux上不起作用。

替代方案是this,但它涉及通过.sh脚本运行program.dll,我不想这样做。

1 个答案:

答案 0 :(得分:0)

目前无法使用该类打开新的控制台窗口。在.NETCore 2.0(issue on .NETCore github

中,Linux上的标志CreateNoWindow被忽略

但是有可用的解决方法 - 使用xterm运行带有.dll进程的新控制台。

        var process = new Process()
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = "xterm",
                Arguments = $"-e dotnet <pathToDll>",
                RedirectStandardOutput = true,
                CreateNoWindow = true,
                UseShellExecute = false,
            },
        };
        process.Start();
相关问题