一尘不染

使用单服务将Windows服务包装在Linux上

linux

嗨,我正在尝试使用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

阅读 310

收藏
2020-06-03

共1个答案

一尘不染

您的LD_LIBRARY_PATH指向哪里?是否libMonoPosixHelper.so在那里?

2020-06-03