Re: Windows Services
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 05/17/04
- Next message: hellrazor: "How do I obtain a reference to an object using the ID?"
- Previous message: Eric: "RE: Remote Folder"
- In reply to: Eric: "Re: Windows Services"
- Next in thread: Eric: "Re: Windows Services"
- Reply: Eric: "Re: Windows Services"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 17 May 2004 12:25:33 -0500
Eric,
Which of the following event log messages are you seeing?
> Log.WriteEntry("FusionDec démarrer avec succès")
> Log.WriteEntry("Erreur lors du démarrage du service : " &
vbCrLf & ex.ToString)
Depending on which you see will indicate if your service is starting or not.
If you are not seeing either then the OnStart is not being reached or is
terminating early.
Are you calling MyBase.OnStart from your OnStart?
More importantly! As I stated, put a try catch in your FusionDec method, so
you know if it failed or not, plus put logging to know it was called.
This way you if you see the success message you know the service started,
then you can look for the FusionDec messages, so you know
You do know that you can have the Windows Installer create the Event Source
& Event Log for you?
> 'Création des logs s'il n'existe pas.
> If Not Log.SourceExists("FusionDec") Then
> Log.CreateEventSource("FusionDec", "FusionDec")
> End If
> Log.Source = "FusionDec"
Drag an EventLog object from the toolbox onto the design surface of your
Windows Service. Set the Log & Source properties. Click the "Add Installer"
link (or right click on EventLog on the designer). This will add an
Installer to your Service Installer.
Also, rather then using your Log property I override the
ServiceBase.EventLog property and return the object created by dragging an
EventLog to the designer. This causes all the automatic messages as well as
my messages to go to the same log. (read you can leave AutoLog=True and the
auto log messages will go to the event log of your choosing).
Public Overrides ReadOnly Property EventLog() As
System.Diagnostics.EventLog
Get
Return Me.EventLog1
' Seeing as you have a Log property you can return it.
Return Log
End Get
End Property
Then I would simply use EventLog
> EventLog.WriteEntry("FusionDec démarrer avec succès")
> EventLog.WriteEntry("Erreur lors du démarrage du service : " &
vbCrLf & ex.ToString)
Hope this helps
Jay
"Eric" <anonymous@discussions.microsoft.com> wrote in message
news:6D80D955-B494-4E88-B5F4-B90630574814@microsoft.com...
> Hi,
>
> This is what I have in my OnStart :
>
> Try
> EcrireErreur("test")
> 'Création des logs s'il n'existe pas.
> If Not Log.SourceExists("FusionDec") Then
> Log.CreateEventSource("FusionDec", "FusionDec")
> End If
> Log.Source = "FusionDec"
>
> 'option du FileSystemWatcher.
> fwFichierFusion.Path = "c:\Test2\"
> fwFichierFusion.Filter = ""
> fwFichierFusion.IncludeSubdirectories = True
>
> fwFichierFusion.EnableRaisingEvents = True
>
> 'Ajout de l'action évènement.
> AddHandler fwFichierFusion.Created, AddressOf FusionDec
>
> Log.WriteEntry("FusionDec démarrer avec succès")
> Catch ex As Exception
> Debug.WriteLine(Err.GetException.ToString())
> EcrireErreur(Err.GetException.ToString())
> Log.WriteEntry("Erreur lors du démarrage du service : " &
vbCrLf & ex.ToString)
> End Try
>
>
> I think it isn't to much in the OnStart() and I can't debug it because it
start and few second after it stop.
>
> by the way thanks for trying
- Next message: hellrazor: "How do I obtain a reference to an object using the ID?"
- Previous message: Eric: "RE: Remote Folder"
- In reply to: Eric: "Re: Windows Services"
- Next in thread: Eric: "Re: Windows Services"
- Reply: Eric: "Re: Windows Services"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|