Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Raspbian中的OS引导上启动Mono程序?_C#_Linux_Mono_Raspberry Pi_Raspbian - Fatal编程技术网

C# 如何在Raspbian中的OS引导上启动Mono程序?

C# 如何在Raspbian中的OS引导上启动Mono程序?,c#,linux,mono,raspberry-pi,raspbian,C#,Linux,Mono,Raspberry Pi,Raspbian,我有一个覆盆子皮2和覆盆子。我试图在系统启动时自动启动一个名为StartBrowser.exe的Mono程序。我在/etc/rc.local文件中添加了以下行: sudo mono /home/pi/Desktop/StartBrowser.exe 我还尝试添加: sudo /home/pi/Desktop/StartBrowser.exe 程序在引导时不会启动。当我在终端中运行相同的命令时,预期的程序启动。在系统启动时启动“StartBrowser.exe”需要做什么?您可以使用“mon

我有一个覆盆子皮2和覆盆子。我试图在系统启动时自动启动一个名为StartBrowser.exe的Mono程序。我在/etc/rc.local文件中添加了以下行:

sudo mono /home/pi/Desktop/StartBrowser.exe
我还尝试添加:

 sudo /home/pi/Desktop/StartBrowser.exe
程序在引导时不会启动。当我在终端中运行相同的命令时,预期的程序启动。在系统启动时启动“StartBrowser.exe”需要做什么?

您可以使用“mono服务”在后台运行程序

您可以这样运行编译后的代码:

mono-service /home/pi/Desktop/StartBrowser.exe
默认情况下,这将在/tmp中创建一个锁文件。您可以使用-l:选项来更改此设置。
通过这种方式,您的服务将在后台运行

完成此操作的步骤很少:

  • 确保应用程序可以作为Windows服务()运行
  • 使用
    sudo apt get install mono-4.0-service在RPi上安装mono服务
  • 现在,您可以在
    rc.local
    文件的末尾,在
    exit 0
    行之前添加以下内容:
  • /usr/bin/mono服务-p:/directory/of/mono/app/directory/of/mono/app/app.exe


    -p
    开关是强制性的,否则不会加载额外的DLL。

    您是先读的吗?您真的是在
    /etc/rc/local
    而不是
    /etc/rc.local
    上写的吗?我仍在为这个问题苦苦挣扎。我尝试使用sudo crontab-e添加以下行:@reboot/home/pi/Desktop/StartBrowser3.exe在启动时仍然无法启动。您从rc.local中的命令中获得了什么输出?如果需要,将
    stdout
    stderr
    重定向到合适的临时日志。我不知道为什么要在rc.local脚本中使用
    sudo
    ——root运行该脚本,因此sudo只会浪费宝贵的启动时间纳秒。