首页 > 解决方案 > StandardOutput.ReadToEnd() 始终为 NULL

问题描述

我有这个功能的问题。它应该将安装命令输出到文本框,但install.StandardOutput.ReadToEnd()始终是null.

我得到错误:Expression cannot be evaluated because there is a native frame at the top of the call stack

你能帮我解决这个问题吗?

Process install = new Process();
install.StartInfo.FileName = "cmd.exe";
install.StartInfo.UseShellExecute = false;
install.StartInfo.Arguments = "/all";
install.StartInfo.CreateNoWindow = true;
install.StartInfo.RedirectStandardInput = true;
install.StartInfo.RedirectStandardOutput = true;
install.Start();

if (CB_MultiADB.Checked == true)
{
    install.StandardInput.WriteLine("FOR /F \"skip=1\" %%x IN ('adb devices') DO start cmd.exe @cmd /k" + InstallOption + InstallPfad + "\"");
}
else
{
    install.StandardInput.WriteLine("adb install" + InstallOption + InstallPfad + "\"");

    InstallAusgabe = install.StandardOutput.ReadToEnd();
    string Index = "adb install";
    int Indexnr = InstallAusgabe.IndexOf(Index);
    string SubInstall = InstallAusgabe.Substring(Indexnr, 100);
    TB_Ausgabe.Text = SubInstall;
}

标签: c#android

解决方案


推荐阅读