嗨,我正在尝试使用mono-service2从Visual Studio中运行库存Windows Service Project。我在单声道2.0的debian上运行它并进行编译。
gmcs *.cs -pkg:dotnet
我尝试从这里开始(我尝试将-d设置为应用程序的目录,并设置了-n,-m)
mono-service2 -l:service.lock --debug Program.exe
唯一的代码更改是添加测试写行
Service1.cs
using System; using System.ServiceProcess; namespace spikes { public partial class Service1 : ServiceBase { public Service1() { InitializeComponent(); } protected override void OnStart(string[] args) { Console.WriteLine("starting..."); } protected override void OnStop() { Console.WriteLine("stopping...."); } } }
结果就是这个错误
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.DllNotFoundException: libMonoPosixHelper.so at (wrapper managed-to-native) Mono.Unix.Native.Syscall:_L_ctermid () at Mono.Unix.Native.Syscall..cctor () [0x00000] --- End of inner exception stack trace --- at MonoServiceRunner.Main (System.String[] args) [0x00000]
谢谢你的帮助
回答
我缺少LD_LIBRARY_PATH env变量,因此我将其添加到csh中进行测试
#!/bin/csh setenv LD_LIBRARY_PATH .:/usr/local/lib mono-service2 -l:service.lock --debug Program.exe
您的LD_LIBRARY_PATH指向哪里?是否libMonoPosixHelper.so在那里?
libMonoPosixHelper.so