Note that there are some explanatory texts on larger screens.

plurals
  1. POC# service as a daemon in debian with mono-service
    primarykey
    data
    text
    <p>I can't seem to find a way to get a C# service run as a "service" in debian. What Am I doing wrong?</p> <p>I followed this post from msdn to create a sample windows service : <a href="http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.80).aspx</a></p> <p>I can run the service at my windows machine, Start and stop the service and see that it writes to MyNewLog.</p> <p>Then I copy it (.exe file) to my debian machine and tries to run it with (as root) mono-service MyNewService.exe</p> <p>The Syslog tell's me that the service have started!</p> <p>I have no errors and I can't see any newly created logfiles in the system. What Am I doing wrong?</p> <p>If it helps, here is the code: Program.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.ServiceProcess; using System.Text; namespace MyNewService { static class Program { /// &lt;summary&gt; /// The main entry point for the application. /// &lt;/summary&gt; static void Main() { System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new MyNewService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); } } } </code></pre> <p>Service.cs</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; namespace MyNewService { public partial class MyNewService : ServiceBase { public MyNewService() { InitializeComponent(); if (!System.Diagnostics.EventLog.SourceExists("MySource")) { System.Diagnostics.EventLog.CreateEventSource( "MySource", "MyNewLog"); } myEventLog.Source = "MySource"; myEventLog.Log = "MyNewLog"; } protected override void OnStart(string[] args) { myEventLog.WriteEntry("Service Started: OnStart"); } protected override void OnStop() { myEventLog.WriteEntry("Service Halted: OnStop."); } } } </code></pre> <p>/Cheers</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload