.NET Service to Linux Daemon

marked picture marked · Jul 5, 2011 · Viewed 8.7k times · Source

I am writing a portable service/daemon using .NET 3.5, my windows service is running, but I was wondering about the mono port...

Mono-service is what I am looking for if I understand correctly. How exactly does this work though? I assume I need mono compatible code throughout my service, right? For example, I am using SQLite. Is it correct that in order to use this with mono I should refactor my code to use mono namespaces etc, such as Mono.Data.SQLite? May I still use Settings.settings?

Also, I've read that daemons don't implement onStart/Stop methods, so do I need to change my code to run under mono/linux? i.e. is it ok to have these methods in my code, and ok to run ServiceBase.Run()? Does Mono-service accommodate these?

Answer

DiableNoir picture DiableNoir · Jul 9, 2011

You should create your programs from the beginning for use with Windows and Linux.

You need Visual Studio with Mono Tools or the free MonoDevelop-IDE to create a Mono-Application. MonoDevelop can import your Visual Studio Project. This IDE helps you to get the right namespaces.

Use Mono-Service to run your Assembly as daemon. Linux Daemons are using Signals to communicate with the System. Please read the documentation.

We already had a similar question, so please read this to see, how to process Unix-Signals.