acool,
Did you try putting EventLog.WriteEntry entries in your OnChanged,
OnCreated, OnRenamed methods to see when or if they are being called?
[color=blue]
> ' Define the event handlers.
> Private Shared Sub OnChanged(ByVal source As Object, ByVal e As
> FileSystemEventArgs)[/color]
EventLog.WriteEntry("OnChanged started", _
EventLogEntryType.Information)
[color=blue]
> ' Specify what is done when a file is changed, created, or[/color]
deleted.
EventLog.WriteEntry("OnChanged ended", _
EventLogEntryType.Information)
[color=blue]
> End Sub[/color]
Are you calling MyBase.OnStart? Did you try putting extra
EventLog.WriteEntry's in your OnStart to make sure it finishes?
Did you use Event Viewer in Control Panel - Admistrative Tools to see your
events that are written above?
Alternatively did you try Trace.Write or Debug.Write and the app.config to
write to a log file to see what is happening?
Did you attempt to debug your app (start it, put break points in OnChanged,
OnCreated, OnRenamed methods) to see what happens?
Hope this helps
Jay
"acool" <none@sendme.com> wrote in message
news:eEJWQLOPEHA.3052@TK2MSFTNGP09.phx.gbl...[color=blue]
> I think I am missing soething here is my code:
>
> Imports System.ServiceProcess
> Imports System.IO
> Imports System.Diagnostics
>
> Protected Overrides Sub OnStart(ByVal args() As String)
> ' Create a new FileSystemWatcher and set its properties.
>
> Dim watcher As New FileSystemWatcher
> watcher.Path = "C:\Temp"
> watcher.Filter = "*.xls"
>
> ' Add event handlers.
> AddHandler watcher.Changed, AddressOf OnChanged
> AddHandler watcher.Created, AddressOf OnCreated
> AddHandler watcher.Deleted, AddressOf OnChanged
> AddHandler watcher.Renamed, AddressOf OnRenamed
>
> ' Begin watching.
> watcher.EnableRaisingEvents = True
>
> End Sub
>
> ' Define the event handlers.
> Private Shared Sub OnChanged(ByVal source As Object, ByVal e As
> FileSystemEventArgs)
> ' Specify what is done when a file is changed, created, or[/color]
deleted.[color=blue]
> End Sub
>
> Private Shared Sub OnRenamed(ByVal source As Object, ByVal e As
> RenamedEventArgs)
> ' Specify what is done when a file is renamed.
> End Sub
>
> Private Sub OnCreated(ByVal source As Object, ByVal e As
> FileSystemEventArgs)
> ' Specify what is done when a file is created.
> File.Create("C:\Temp\OnCreated.txt")
> End Sub
>
> So basically when I drop an excel file in my temp folder I want the
> OnCreated event to do something. This works fine in a form but not in my
> service. I knw I am missing something I just don't know what.
>
>
>
>
>
>
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:OniN85NPEHA.3988@tk2msftngp13.phx.gbl...[color=green]
> > Are you doing too much work in the OnStart method?
> >
> > Have you tried debugging your service:
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...owsservice.asp[color=blue][color=green]
> >
> > Specifically:
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...plications.asp[color=blue][color=green]
> >
> > Normally what I do is include a healthy amount of event log messages[/color][/color]
(via[color=blue][color=green]
> > theServiceBase.EventLog property ) especially in any asynchronous events
> > that may be raised within the service. Plus I will include Debug.Write &
> > Trace.Write in strategic locations.
> >
> > Something like:
> >
> > Public Class MyService
> > Inherits System.ServiceProcess.ServiceBase
> >
> > Private WithEvents Timer1 As System.Timers.Timer
> >
> > Public Sub New()
> > MyBase.New()
> >
> > ' This call is required by the Component Designer.
> > InitializeComponent()
> >
> > ' Add any initialization after the InitializeComponent() call
> >
> > AddHandler AppDomain.CurrentDomain.UnhandledException, _
> > AddressOf AppDomain_UnhandledException
> > End Sub
> >
> > Protected Overrides Sub OnStart(ByVal args() As String)
> > ' Add code here to start your service. This method should set[/color]
> things[color=green]
> > ' in motion so your service can do its work.
> > Timer1.Start()
> > End Sub
> >
> > Protected Overrides Sub OnStop()
> > ' Add code here to perform any tear-down necessary to stop your
> > service.
> > Timer1.Stop()
> > End Sub
> >
> > Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
> > System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
> > Try
> > EventLog.WriteEntry("Timer elapsed handler started",
> > EventLogEntryType.Information)
> >
> > ' Do work here
> >
> > EventLog.WriteEntry("Timer elapsed handler finished",
> > EventLogEntryType.Information)
> > Catch ex As Exception
> > EventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error)
> > End Try
> > End Sub
> >
> > Private Sub AppDomain_UnhandledException(ByVal sender As Object, _
> > ByVal e As UnhandledExceptionEventArgs)
> > EventLog.WriteEntry(e.ExceptionObject.ToString(),
> > EventLogEntryType.Error)
> > End Sub
> >
> >
> > End Class
> >
> > Note EventLog is inherited from ServiceBase and will be the normal event[/color]
> log[color=green]
> > for your service, you can override ServiceBase.EventLog if you want to[/color][/color]
use[color=blue]
> a[color=green]
> > different Event log.
> >
> > I configure Debug & Trace to go to a log file.
> >
> > In your app.config of your Windows Service project:
> > <?xml version="1.0" encoding="utf-8" ?>
> > <configuration>
> > <system.diagnostics>
> > <trace autoflush="true" indentsize="4">
> > <listeners>
> > <add name="myListener"[/color]
> type="System.Diagnostics.TextWriterTraceListener"[color=green]
> > initializeData="MyService.log" />
> > </listeners>
> > </trace>
> > </system.diagnostics>
> > </configuration>
> >
> >
> > Note the UnhandledException event is not working as I expected in the[/color]
> above,[color=green]
> > so I put the Elapsed event in its own Try/Catch.
> >
> > Hope this helps
> > Jay
> >
> >
> > "acool" <none@sendme.com> wrote in message
> > news:O1uDD1NPEHA.2452@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > I managed to get my VB.NET service installed. Now I can't get it to do
> > > anything. Tell me how do you debug smething like this if you have to
> > > manually install the assembly to run it? the same code works just fine[/color][/color]
> in[color=green]
> > a[color=darkred]
> > > VB form but when I initiallize with the WS OnStart event I get[/color][/color][/color]
nothing.[color=blue][color=green]
> > Any[color=darkred]
> > > help is greatly appreciated.
> > >
> > >
> > >
> > > TB
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]