Bill Greer
Bill Greer

Reputation: 3166

How do I start a Mono Program on OS boot in Raspbian?

I have a Raspberry Pi 2 with Raspbian. I am trying to start a Mono program called StartBrowser.exe automatically when the system boots. I added the following line to the /etc/rc.local file:

sudo mono /home/pi/Desktop/StartBrowser.exe

I also tried adding:

 sudo /home/pi/Desktop/StartBrowser.exe

The program does not start on boot. When I run the same commands in the terminal the expected program starts. What do I need to do to start "StartBrowser.exe" on system boot ?

Upvotes: 1

Views: 3005

Answers (2)

Vir
Vir

Reputation: 652

There are few steps to accomplish this:

  1. Make sure your application can be run as Windows Service (check the documentation)
  2. On RPi install mono-service with sudo apt-get install mono-4.0-service
  3. Now you can add, at the end of the rc.local file, just before exit 0 line this call:

/usr/bin/mono-service -p:/directory/of/mono/app /directory/of/mono/app/app.exe

-p switch is mandatory, otherwise no additional DLLs will be loaded.

Upvotes: 2

Francesco
Francesco

Reputation: 372

You can use "mono-service" to run programs in the background.

You can run your compiled code like so:

mono-service /home/pi/Desktop/StartBrowser.exe

By default, this creates a lockfile in /tmp. You can change this by using the -l: option. In this way your service is running in the background

Upvotes: 1

Related Questions