I've got an asp.net mvc website up and running great on the pi, and I'm even blinking an led - however, I would like to take a picture from the site using the raspberry pi camera board. I am attempting to use the following code:

Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "raspistill -o image.jpg";
proc.StartInfo.UseShellExecute = false; 
proc.StartInfo.RedirectStandardOutput = true;

However, every time I try to do that I get the error

user/bin/raspistill: /usr/bin/raspistill: cannot execute binary file

Does anyone have any idea why this isn't working, or how I can run a bash command from mono/C#?

  • have you tried to run the same command from the terminal? what was the result?
    – lenik
    Sep 9, 2013 at 0:19
  • 1
    How are you running asp.net and mono on your Pi? I tried installing mono and xsp2 and xsp4 but couldn't get a simple web page to run. Sep 9, 2013 at 1:18
  • @lenik - when done from the terminal it works exactly as intended. Sep 9, 2013 at 1:46
  • @HeatfanJohn - I followed this tutorial exactly and it worked quite well codewithmac.com/2013/05/asp-net-mvc-on-your-raspberry-pi - the key is installing Debian, not Raspian Sep 9, 2013 at 1:47
  • Ah, I'm not running soft-float Sep 9, 2013 at 2:32

1 Answer 1



You need to add the -c option to the argument string for /bin/bash:

    proc.StartInfo.Arguments = "-c raspistill -o image.jpg";

I get the same cannot execute binary file when I try to run /bin/bash /usr/bin/raspistill -? from the command line.

    raspberrypi ~ $ /bin/bash /usr/bin/raspistill -?
    /usr/bin/raspistill: /usr/bin/raspistill: cannot execute binary file

Running /bin/bash -c /usr/bin/raspistill -? works from the command line.

Also, according to this SO article try running /usr/bin/raspistill directly from Process.Start() as shown below:

    Process.Start("/usr/bin/raspistill", "-?");
  • That's the one! It works perfectly Sep 13, 2013 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.