2013-10-03 47 views
0

我需要在Ubuntu启动时运行c#Windows窗体应用程序(Mono应用程序),然后尝试使用Upstart。我手动运行该应用程序很好,但是当我使用了Upstart脚本,如下:在启动时使用Upstart运行单应用程序

description "Indsys Andon" 

start on runlevel [2345] 
stop on runlevel [016] 

setuid nobody 
setgid nogroup 
respawn 
console log 

script 
    /usr/bin/mono /usr/lib/IndsysAndon/IndsysAndon.exe "[email protected]" 
end script 

在Indsys.exe.log出现错误消息:

A Unhanled Exception : System.TypeInitializationException: An exception was throw 
Parameter name: Display 
... 

当我使用脚本How do I add my mono Program to the startup? ,所以,在Indsys.exe.log错误消息是:

run-detectors: unable to find an interpreter for /usr/lib/IndsysAndon/IndsysAndon.exe 

我不知道的权利,但我认为我需要的是非常简单的。真的有必要使用Upstart?我也尝试rc.local失败,插入:

/usr/bin/mono /usr/lib/IndsysAndon/IndsysAndon.exe 

有人帮助我,请。谢谢,

+0

我一直在成功运行KeePass.exe之后出现同样的错误。终端的重新启动修复了我的问题。 –

回答

0

您可以尝试制作脚本来调用您的应用程序,例如:

#!/bin/sh 
    exec /usr/bin/mono PREFIX/lib/APPLICATION/app.exe "[email protected]" 

然后从暴发户调用该脚本?这是一个漫长的时间,因为我已经做到了这一点,但我似乎记得做类似的东西...

这也可能会有所帮助:Application Deployment

+0

谢谢你回答TheNextman。我创建了一个类似于你的脚本_IndsysAndon.sh,并在IndsysAndon.exe.conf中使用'sh/usr/lib/IndsysAndon/IndsysAndon.sh'编写了一个脚本,但是错误仍然相同:'一个未引用的异常: System.TypeInitializationException:...'再次感谢。 –

+0

什么是完整的例外? – TheNextman

+0

这就像伊拉尔回答。谢谢 –

1

我觉得单的WinForms应用程序需要一个有效运行的Xserver和一个有效的DISPLAY环境变量。它应该从X会话运行或重定向到有效的输出(它可以在另一台机器上)。

要验证,请尝试从控制台预先运行“DISPLAY =''”来运行您的应用程序。

我得到了同样的错误,试图用空的DISPLAY变量启动keepass(一个winforms应用程序)。

$ DISPLAY= /usr/bin/mono /usr/share/keepass/KeePass.exe 

Unhandled Exception: 
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.ArgumentNullException: Could not open display (X-Server required. Check you DISPLAY environment variable) 
Parameter name: Display 
    at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] in <filename unknown>:0 
    at System.Windows.Forms.XplatUIX11..ctor() [0x00000] in <filename unknown>:0 
    at System.Windows.Forms.XplatUIX11.GetInstance() [0x00000] in <filename unknown>:0 
    at System.Windows.Forms.XplatUI..cctor() [0x00000] in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at System.Windows.Forms.Application.EnableVisualStyles() [0x00000] in <filename unknown>:0 
    at KeePass.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.ArgumentNullException: Could not open display (X-Server required. Check you DISPLAY environment variable) 
Parameter name: Display 
    at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] in <filename unknown>:0 
    at System.Windows.Forms.XplatUIX11..ctor() [0x00000] in <filename unknown>:0 
    at System.Windows.Forms.XplatUIX11.GetInstance() [0x00000] in <filename unknown>:0 
    at System.Windows.Forms.XplatUI..cctor() [0x00000] in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at System.Windows.Forms.Application.EnableVisualStyles() [0x00000] in <filename unknown>:0 
    at KeePass.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

也许你可以设置一个虚拟的X服务器,这个问题可以帮助你:What dummy X server should I use with openoffice on debian?

+0

谢谢你回答ilarrain。我得到的错误与您的错误相同。我尝试像[链接](http://en.wikipedia.org/wiki/Xvfb)配置Xvfb,但我还没有成功。如果您对此有所了解,欢迎光临。再次感谢。 –

相关问题