Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Service doesn't start

Status
Not open for further replies.

ofsouto

Programmer
Joined
Apr 29, 2000
Messages
185
Location
BR
Hi, dear

I created a Windows Service Application and I can't start it.
When I remove the System.Timers.Timer the service starts but I need the System.Timers.Timer on application.

When I try to start the service a message shows up:
The service 'XXXX' in Local System was started and stopped. Some services are stopped automatically when there isn't no work, as Logs Service and Performance Alerts.

What's wrong? What can I do to solve this problem?

Thank's in advance.

Obede
 
The Event Logs shows the message bellow:

Service cannot be started. System.NullReferenceException: Object reference not set to an instance of an object.
at Servico_Teste.GC_Carga_Automatica.OnStart(String[] args) in C:\SistCli\net\Gestor Crédito PJ - Carga Automática WEB II\Service1.vb:line 72
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

line 72

GCTimer.Interval = System.Configuration.ConfigurationSettings.AppSettings("Intervalo")

app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Intervalo" value="900000"></add>
</appSettings>
</configuration>
 
You need more information about what's happening.

You can use the EventLog class from System.Diagnostics to write debug messages to the NT event log:
Code:
Dim el As New EventLog("Application")

' Set up source if it doesn't already exist
If Not EventLog.SourceExists("MySourceName", Environment.MachineName) Then
	EventLog.CreateEventSource("MySourceName", _
		"Application", Environment.MachineName)
End If

' Write debug message
el.WriteEntry("My message goes here", EventLogEntryType.Information)

Chip H.

____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
When I set a value to interval as:
GCTimer.Interval = 1000
the service start but when I set a value as :
Dim dbInterva As Double = Double.Parse("0" & System.Configuration.ConfigurationSettings.AppSettings("Intervalo"))
GCTimer.Interval = dbIntervalo
the service doesn't start and the message bellow (Event log) shows up:

Service cannot be started. System.ArgumentException: '0' is not a valid value for 'Interval'. 'Interval' must be greater than 0.
at System.Timers.Timer.set_Interval(Double value)
at Servico_Teste.GC_Carga_Automatica.OnStart(String[] args) in C:\SistCli\net\Gestor Crédito PJ - Carga Automática WEB II\Service1.vb:line 72
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
 
Where is dbIntervalo initialized?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top