Hi Peter and Joerg,

I've been digging around for the whole week in order to make the mono-service work, the attached TestService code saved me a lot of time. Very appreciate. I compiled and ran it on my machine (Suse 10 desktop), it's working fine on the command line. Here are my observations and questions:

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

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.

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.

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?

Thanks,

Wilson


From: Jörg Rosenkranz <[EMAIL PROTECTED]>
To: "Bradley, Peter" <[EMAIL PROTECTED]>,"WILSON LEI" <[EMAIL PROTECTED]>,<mono-list@lists.ximian.com>
Subject: RE: [Mono-list] mono-service
Date: Tue, 1 Nov 2005 13:31:16 +0100

Hi all,
?lt;/div>
I suppose you are missing the ServiceBase.Run call in your Main method:
?lt;/div>
 System.ServiceProcess.ServiceBase[] servicesToRun;
 servicesToRun = new System.ServiceProcess.ServiceBase[] { new TestService("TestService1")};
 System.ServiceProcess.ServiceBase.Run(servicesToRun);
?lt;/div>
This method then calls your OnStart function.
I have attached a sample service I made some time ago as bug test case. Maybe this is helpfull for you.
?lt;/div>
Another idea: mono-service logs errors into syslog. Did you look into /var/log/messages?
?lt;/div>
Joerg.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bradley, Peter
Sent: Tuesday, November 01, 2005 11:08 AM
To: WILSON LEI; mono-list@lists.ximian.com
Subject: RE: [Mono-list] mono-service

Could I take the opportunity to add my voice to this??I was intending to post something similar when I’d done a bit more work on the topic, but Wilson has beaten me to it.

?lt;/span>

The mono-service man pages are very sparse.?If I can get it working, I’d be very happy to write it up as a How-To sort of document for others.

?lt;/span>

Thanks

?lt;/span>

?lt;/span>

Peter

?lt;/span>


From: WILSON LEI [mailto:[EMAIL PROTECTED]
Sent: 31 October 2005 13:44
To: mono-list@lists.ximian.com
Subject: [Mono-list] mono-service

?lt;/span>

Hi,

?lt;/span>

I am trying to port a windows service project to Linux (SuSE 10 Desktop). The project compiles fine and I have an EXE. I then add mono-service myservice.exe into my startup script, however, the service is not started. I got an error saying "Exec format error". Could someone help me on this?

?lt;/span>

I also complied a simplest service and tried to run it on Linux using mono-service, I saw the Main() was called but the OnStart() function is not. Could someone guide me how to make a service on Linux just like a daemon?

?lt;/span>

Thanks,

?lt;/span>

Wilson


><< TestService.cs >>

_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to