This project has moved and is read-only. For the latest updates, please go here.

Unhandled Exception

Topics: Errors
Feb 8, 2016 at 3:44 PM
When running a task and the task errors off I'm getting an unhandled exception error of:

System.ArgumentException was unhandled
Message: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: The path is not of a legal form.

I have try catches in every method and cannot catch this error. I believe it is coming from the Task Scheduler but I'm unsure to why.

Has anyone else run into this? Should I be handling task errors through my code?
Feb 8, 2016 at 3:51 PM
I should clarify that I'm running the task through my code but this also happens when the task tries to run on it's own while my application running and monitoring it.
Feb 8, 2016 at 4:32 PM
Here is my stack:

Application: TaskServiceMonitor.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
at System.IO.Path.NormalizePath(System.String, Boolean, Int32, Boolean)
at System.IO.Path.GetDirectoryName(System.String)
at Microsoft.Win32.TaskScheduler.TaskEventWatcher.Watcher_EventRecordWritten(System.Object, System.Diagnostics.Eventing.Reader.EventRecordWrittenEventArgs)
at System.Diagnostics.Eventing.Reader.EventLogWatcher.IssueCallback(System.Diagnostics.Eventing.Reader.EventRecordWrittenEventArgs)
at System.Diagnostics.Eventing.Reader.EventLogWatcher.HandleEventsRequestCompletion()
at System.Diagnostics.Eventing.Reader.EventLogWatcher.RequestEvents()
at System.Diagnostics.Eventing.Reader.EventLogWatcher.SubscribedEventsAvailableCallback(System.Object, Boolean)
at System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context(System.Object, Boolean)
at System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context_f(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(System.Object, Boolean)
Feb 9, 2016 at 5:54 PM
Thanks for the great detail. This is an error with the TaskEventWatcher and how it handles getting the task name from the System Event Log. It appears that in your case it cannot parse the task name. I'll look into those conditions. If you could reply and let me know if you are monitoring all tasks, all tasks in a folder or a single task (with it's name), that may help me diagnose the problem. I'll also add some error handling to that method to prevent the problem you're seeing. This is a relatively new addition to the library so I appreciate you helping me find the corner cases that can cause failures.
Feb 10, 2016 at 4:21 AM
I have adjusted the handler to a much more predictable behavior and have added a bunch of error handling. In 2.5.14, this should be fixed.
Marked as answer by dahall on 2/10/2016 at 11:01 AM
Feb 10, 2016 at 3:14 PM
You're welcome and I appreciate all of the hard work you are doing with this Task Scheduler wrapper it has come in really handy with the current project I'm working on. In regards to what tasks I'm watching, I'm watching all of the tasks in the root folder.

The TaskEvenWatcher is set up like this:

Task Folder is set to "\"
Filter is set to "*"
Include Sub folders is set to True

Hope this helps. Any idea when 2.5.14 will be available to dl?
Feb 10, 2016 at 6:34 PM
Once I have done a few days of testing, I'll ship it out. I think I have it figured out and am just testing across all the environments.
Feb 10, 2016 at 7:49 PM
Perfect, thanks again.