FileSystemWatcher Crash


i using system.io.filesystemwatcher monitor directory on unc path.  i have used quite bit in other scripts, , never ran issues.  however, past day or so, have been getting random crashes.  today running locally, try , identify cause, , able reproduce it, , got following error.

---------------------------
system.appdomain
---------------------------
illegal characters in path.
   at system.io.path.checkinvalidpathchars(string path, boolean checkadditional)
   at system.io.path.getfilename(string path)
   at system.io.filesystemwatcher.matchpattern(string relativepath)
   at system.io.filesystemwatcher.notifyfilesystemeventargs(int32 action, string name)
   at system.io.filesystemwatcher.completionstatuschanged(uint32 errorcode, uint32 numbytes, nativeoverlapped* overlappedpointer)
   at system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)
   at system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)
   at system.threading._iocompletioncallback.performiocompletioncallback(uint32 errorcode, uint32 numbytes, nativeoverlapped* poverlap)

however, error appears happening internal notify event, , unable catch error code handle it.

any advice?

justin


justin


the fsw has error event can enabled , call error action block:

https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.error(v=vs.110).aspx

this allow take action.  hardest issue when buffer overflows.  action code should short , post job if code complex.

i recommend no more 10 lines of action code in event.


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS