使用 mono-service 在 linux 上封装一个 windows 服务 [英] using mono-service to wrap a windows service on linux

查看:15
本文介绍了使用 mono-service 在 linux 上封装一个 windows 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用 mono-service2 从 Visual Studio 运行库存 Windows 服务项目.我正在使用 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 环境变量,所以我将它添加到 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?

这篇关于使用 mono-service 在 linux 上封装一个 windows 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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