Using a mono service to port a Windows service to Linux

Hi, I am trying to use mono-service2 to run a Windows Service Project from visual studio. I run this on debian with mono 2.0 and compile with.

gmcs *.cs -pkg:dotnet 

I'm trying to start with this (I tried with -d to install to the directory with the application and -n, -m set)

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

The only code change is to add scripts 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...."); } } } 

This error occurs as a result.

 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 the help

Answer

I missed the env variable LD____LIBRARY____PATH, so I added it to csh for the test

 #!/bin/csh setenv LD_LIBRARY_PATH .:/usr/local/lib mono-service2 -l:service.lock --debug Program.exe 
+13
linux mono mono-service
Dec 09 '08 at 6:39
source share
2 answers

Where is your LD_LIBRARY_PATH located? Is there libMonoPosixHelper.so ?

+8
Dec 09 '08 at 7:50
source share

Make sure you have libmono0 installed.

0
Dec 09 '08 at 9:11
source share



All Articles