[Mono-list] mono-service

Jörg Rosenkranz joergr at voelcker.com
Tue Nov 1 11:41:48 EST 2005


Hello Wilson,

1. You were creating 2 services in the MainClass, but only TestService1 called the OnStart(), although both services were disposed at the end. 

Two services can live together in one EXE. Mono-service can start only one at a time (select using -n parameter, default is first), on windows you are able to start both using the service controller. The behaviour should be equivalent to .NET. In most cases there will be only one service in one EXE.

2. The whole structure of your TestService is different from a Windows service created on Visual Studio.NET. On VS.NET, the Main() is included within the Service class, which inherits the ServiceBase. I was porting a Windows project to Linux so the Windows structure was used, and obviously it didn't work on Linux. This is not documented anywhere so for developers trying to make a mono service to work, it really gives us a hard time. 

My test service was created initially on Windows and it runs on Windows too. I don't know what you are doing differently. What do your service body look like? I'm using VS 2003/.NET 1.1. 

3. The Test Service works fine on the command line, but the whole point is to run it at system startup, so I created an init script following the guide given by Novell (http://www.novell.com/coolsolutions/feature/15380.html). However, the startproc command throws me an error: "cannot execute binary file.", but run it from a command line is fine (startproc /usr/bin/mono-service /path/to/TestService.exe). So I am stuck again when trying to run a mono service at startup, hope you could help me out. 

IIRC startproc is for running exes only. Mono-service is a wrapper shell script. Try using startproc /usr/bin/mono /usr/bin/mono-service.exe /path/to/TestService.exe. 

4. How can I join the mono-list so my emails won't get bounced back? 

?? 

5. I really want to write something about porting a mono service after I get my current project done. The material about this area is really rare. Where would be the best place to post, say an article with sample source code? 

 The best place would be the Wiki on http://www.mono-project.com/ but I don't know how accounts are given to new users.

Joerg.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20051101/458e69ee/attachment.html


More information about the Mono-list mailing list