using mono-service to wrap a windows service on linux

断了今生、忘了曾经 提交于 2019-11-26 19:15:47

问题


Hi I'm trying to use mono-service2 to run a stock Windows Service Project from visual studio. I'm running this on debian with mono 2.0 and compiling with.

gmcs *.cs -pkg:dotnet

I try and start with this (I've tried with -d set to the dir with the app and -n,-m set)

mono-service2 -l:service.lock --debug Program.exe

The only code change is to add writelines for testing

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....");
        }
    }
}

The resulting is this error

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]

Thanks for your help

Answer

I was missing the LD____LIBRARY____PATH env variable, so I added it in a csh for a test

#!/bin/csh
setenv LD_LIBRARY_PATH .:/usr/local/lib
mono-service2 -l:service.lock --debug Program.exe

回答1:


Where is your LD_LIBRARY_PATH pointing to? Is libMonoPosixHelper.so in there?




回答2:


Make sure you have libmono0 installed.



来源:https://stackoverflow.com/questions/351971/using-mono-service-to-wrap-a-windows-service-on-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!