0

I have a problem with this function. It is supposed to output an install command to a textbox but install.StandardOutput.ReadToEnd() is always null.

I get the error: Expression cannot be evaluated because there is a native frame at the top of the call stack

Can you help me out with this?

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;
}
DaggeJ
  • 2,094
  • 1
  • 10
  • 22
Kevin M.
  • 1
  • 3
  • `Expression cannot be evaluated because there is a native frame at the top of the call stack` is something one usually sees while using a debugger. Have you tried to run your application outside of the debugger? How does it behave itself? – Eugene Podskal Mar 11 '20 at 20:14
  • You may also be interested in reading https://stackoverflow.com/questions/7160187/standardoutput-readtoend-hangs – Eugene Podskal Mar 11 '20 at 20:16
  • it crashes, cannot be closed and doesnt respond at all, even outside the debugger. i use almost the same function in another part of my Code and it doesnt seem to be a problem there. – Kevin M. Mar 11 '20 at 21:04
  • 1. Does it crash with `CB_MultiADB.Checked == true` only or can you reproduce the behaviour in a simpler branch? 2. Application crashes - does it throw any exception that you can log in a try-catch? If it really crashes hard, then there are still some ways - https://stackoverflow.com/questions/3792456/how-to-debug-a-program-when-it-crashes-w-out-exception 3. Have you tried to reproduce this behavious with some standard or dummy application instead of the adb? – Eugene Podskal Mar 11 '20 at 21:19
  • 1. It does not crash when `CB_MultiADB.Checked == true` 2. there is no exception i could catch, it seems to crash hard but the `procdump -e` didnt throw any information about the error 3. yes, it crashes too with dummy applications because of the `StandardOutput.ReadToEnd()` being null – Kevin M. Mar 11 '20 at 22:38

0 Answers0