使用单服务将Windows服务包装在Linux上 [英] using mono-service to wrap a windows service on linux

查看:85
本文介绍了使用单服务将Windows服务包装在Linux上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用mono-service2从Visual Studio中运行库存Windows Service Project.我正在使用mono 2.0在debian上运行此代码并进行编译.

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

我尝试从此开始(我尝试将-d设置为应用程序的目录,并设置了-n,-m设置)

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

结果是此错误

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中进行测试

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

推荐答案

您的LD_LIBRARY_PATH指向哪里? libMonoPosixHelper.so在里面吗?

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

这篇关于使用单服务将Windows服务包装在Linux上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆