.NET Framework - Anyone else found that PSEventing 1.0 doesn't seem to do anything?
Asked By Duncan Smith
30-Jul-07 12:39 PM
After installing the latest version 1.0 of PSEventing, running the
snap-in and trying the suggested steps to trap events - I'm finding
that no events are collected - is this a common issue that there may
be a work-around or fix?
1# $fsw = new-object system.io.filesystemwatcher
2# $fsw.path = "c:\temp"
3# $fsw.EnableRaisingEvents = $true
4# Connect-EventListener fsw changed,deleted
5# Get-EventBinding fsw | format-table -auto
VariableName EventName TypeName Listening
------------ --------- -------- ---------
fsw Changed FileSystemWatcher True
fsw Deleted FileSystemWatcher True
6# "foo" > c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
8# $events = Get-Event
9# $events | format-table -auto
10#
Thanks,
Duncan
FileSystemWatcher
(1)
EventListener
(1)
VariableName
(1)
EventName
(1)
TypeName
(1)
System.io.filesystemwatcher
(1)
Debugview
(1)
Listener
(1)
Ozone replied...
I am not sure about fsw events, but I have been using version 1.0 with
WMI eventing to capture process activities. The only issue I have is
that the event queue is cleared when the Get-Event cmdlet is
executed. I will do some testing with capturing fsw events, and let
you know if I have any issues...
HTH
Ozone
Duncan Smith replied...
Thanks. I think the man pages for Get-Event state that the events are
cleared by design - otherwise you'd have to enumerate through an ever
increasing list of events, most of which you'll already have had a
chance to process.
It'd be good to see what results you get by following the above steps
on the fsw.
Thanks,
Duncan
Oisin Grehan replied...
Hi Duncan,
I cannot reproduce this using the 1.0 release. This is very weird...
I'll put an instrumented / debug build up somewhere for you to
download and install. This will generate verbose debug messages to a
connected listener (like sysinternal's debugview) and then perhaps you
can send me this log after you have repro'd the issue using the above
steps.
- Oisin
Duncan Smith replied...
I'll gladly give the debug build a go when you have one available,
thats very kind. Meanwhile, I'll try the steps on a different pc and
also write a c# or cpp app to drive the fsw - see what happens.
Many thanks,
Duncan
Duncan Smith replied...
Hello again,
I just tried the same steps on a different laptop and got the same
results :-( But then I noticed the 'eventhandler.ps1' source
available as a separate download - after I dot-sourced this and
followed the steps just above the 'How does it work section' I now get
the events :-) This looks jolly useful.
Thanks for the help
Duncan

Problems with Filesystemwatcher and Web Service .NET Framework I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher, monitors a folder and then returns the contents of the new / changed files. However, if two watchers which is causing a few problems. Is there anyway to tell if a filesystemwatcher already exists and is watching the folder? Or that the webservice that created the first watcher is still running? .NET Web Services Discussions FileSystemWatcher.Dispose (1) WebMethodAttribute (1) ThreadPool (1) VB (1) Encoding (1) Dispose (1) GC (1) WebMethod use it. Do you enable session in your Web Service? If so, do you add FileSystemWatcher object into the Session collection? Regarding your question, I do think it should not be Web Method will be released automatically by the stack unwind. Since the references to the FileSystemWatcher disappeared, the FileSystemWatcher object will be collected by the GC in future or immediately based on the GC
actually invoking: var val = Application.Contents.Item("y") Since JS doesn't have the handy TypeName function, it's easier to demo this in VBScript code: * ** ** ** * junk.asp * ** ** ** * Session("foo") = "bar" Response.Write "TypeName(Session) is " & TypeName(Session) & " " Response.Write "TypeName(Session.Contents) is " & TypeName(Session.Contents) & " " Response.Write TypeName(Session.Contents.Item(foo)) is " & TypeName(Session.Contents.Item("foo")) & " " Response.Write "TypeName(Session(foo)) is " & TypeName(Session("foo")) & %> * ** ** ** ** ** ** ** ** * The output of that is, not horribly surprisingly: TypeName
Diagnostics Imports System.Data.SqlClient Imports System.Text.RegularExpressions Public Class NoticeImport Private watchFolder As FileSystemWatcher Private dataSource As String, _ dataBase As String, _ userName As String, _ password As As System.Object, ByVal e As System.EventArgs) Handles btnStartWatching.Click watchFolder = New System.IO.FileSystemWatcher() 'Get the db login info and the location of the input text files from the ss") & ")." & vbCrLf End Sub End Class VB.NET Discussions System.IO.FileSystemEventArgs (1) System.IO.FileSystemWatcher (1) System.IO.RenamedEventArgs (1) LPedne8bw6RwFSrVnZ2dnUVZ (1) System.Threading.Thread.Sleep (1) DlnpFntCalcs.DlnpFntCalcs (1) System.Data.SqlClient (1) SqlDbType.VarChar (1) Is it possible that the FileSystemWatcher is "jumping on" the / same / file twice in rapid succession? I've noticed that the FileSystemWatcher has a nasty habit of raising multiple events when you might only expect one and doing so in a very short space of time. I suspect the FileSystemWatcher has its own Thread, so straight away you're into the nastiness of cross-threading Phil but SyncLock didn't do it. And you could be right. I read that FileSystemWatcher can raising multiple events somewhere. It could be using a single file more than once In fact that was what I first set up before I found out about the FileSystemWatcher class. I had set up a routine to look for text files in the folder
FileSystemWatcher .NET Framework Hallo, ich habe eine Anwendung mit einem Labelelement, welches immer dann den Text wenn eine XML-Datei in dem Anwendungsverzeichnis geändert wird. Dazu habe ich herausgefunden, dass dafür FileSystemWatcher benutzt werden kann. Wie kann ich damit meine Anwendung laufen lassen und parallel dazu mein Ich habe eine Komponente erstellt, abgeleitet von Label: namespace DynText { public partial class DynText : Label { FileSystemWatcher watcher = new FileSystemWatcher(); } private string filename = string.Empty; public string Filename { get { return filename; } set { filename = value; } } private string variablename = string.Empty; public string Variablename { get { return variablename; } set { variablename = value; } } private string poolfolder = string.Empty; public string Poolfolder { get { return poolfolder; } set { poolfolder = value
FileSystemWatcher et multiples events .NET Framework Bonjour. J'ai des probl = E8mes d'events lev = E9s class FileObjectMapper { private readonly string m_File = 3D null; private readonly FileObjectMapperHandler m_Callback = 3D null; private FileSystemWatcher m_FileWatcher = 3D null; public FileObjectMapper(string pFile, FileObjectMapperHandler pCallback, bool pLoadIfExists) { m_File = 3D Path.GetFullPath m_File)) { this.OnFileChangedOrCreated( this, new FileSystemEventArgs(WatcherChangeTypes.All, Path.GetDirectoryName(m_File), m_File)); } m_FileWatcher = 3D new FileSystemWatcher(Path.GetDirectoryName(m_File), Path.GetFileName(m_File)); m_FileWatcher.NotifyFilter = 3D NotifyFilters.LastWrite; m_FileWatcher.Created + = 3D new cr = E9 = E9 le fichier, aucun event lev = E9. . . Comment ce fait-il que le FileSystemWatcher pose autant de probl = E8mes ?! Je ne suis pas le seul dans ce cas l to call the program. Console.WriteLine("Usage: Watcher.exe (directory)"); Console.ReadLine(); } / / Create a new FileSystemWatcher and set its properties. FileSystemWatcher watcher = 3D new FileSystemWatcher(); watcher.Path = 3D "C: \ TEMP"; / / args[1]; / * Watch for changes in LastAccess and LastWrite times IDisposable { private readonly string m_File = 3D null; private readonly FileObjectMapperHandler m_Callback = 3D null; private readonly FileSystemWatcher m_FileWatcher = 3D null; private DateTime m_LastEvent; public FileObjectMapper(string pFile, FileObjectMapperHandler pCallback) { if (pFile = 3D