5

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;
proc.Start();

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#?

asked Sep 8, 2013 at 19:33
6
  • have you tried to run the same command from the terminal? what was the result? Commented 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. Commented Sep 9, 2013 at 1:18
  • @lenik - when done from the terminal it works exactly as intended. Commented 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 Commented Sep 9, 2013 at 1:47
  • Ah, I'm not running soft-float Commented Sep 9, 2013 at 2:32

1 Answer 1

3

Update

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", "-?");
answered Sep 9, 2013 at 15:23
1
  • That's the one! It works perfectly Commented Sep 13, 2013 at 2:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.