您好我正在尝试使用mono-service2从visual studio运行一个Windows Service Project。我在使用mono 2.0并使用。编译的debian上运行它。
gmcs *.cs -pkg:dotnet
我尝试从这开始(我已尝试将-d设置为带有app的dir和-n,-m设置)
mono-service2 -l:service.lock --debug Program.exe
唯一的代码更改是添加用于测试的writelines
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
答案 0 :(得分:9)
你的LD_LIBRARY_PATH指向哪里?那里有libMonoPosixHelper.so
吗?
答案 1 :(得分:0)
确保已安装 libmono0 。