I have wrote a window service and it giving error while start.
Error:The Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs.
I also got error detail in window log as:
Service cannot be started. System.ArgumentException: The source 'SampleWindowService' is not registered in log 'windowLogDemo'. (It is registered in log 'DemoService'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property. at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName) at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte rawData) at System.Diagnostics.EventLog.WriteEntry(String message) at WindowsServiceDemo.Service1.OnStart(String args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
log is not full.So no memory issue is there I think.
my code goes here:
private const string sourceName = "SampleWindowService";
protected override void OnStart(string args)
this.eventLog1.Source = sourceName;
// this.eventLog1.Log = "windowLogDemo";
this.eventLog1.WriteEntry("Service started successfully");
myTimer.Interval = 60000;
myTimer.Elapsed += new ElapsedEventHandler(timer1_Elapsed);