locked
Problem with WorkflowApplication and OnUnhandledException RRS feed

  • Question

  • I'm using a WorkflowApplication object to schedule running my workflows.  I am setting Completed, Aborted, and OnUnhandledException with appropriate handlers.  When my workflow completes successfully, I reach my Completed handler.  However, when my workflow throws an exception, it just dies with a thread terminated exception.  I do not reach my OnUnhandledException handler.

    What gives?

    Chuck


    Chuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.
    Thursday, April 15, 2010 10:34 PM

All replies

  • Hi Chuck,

    What is the exception and do you know what activity is throwing it and from what part of the activity? That does sound unusual. Is it possible that a new exception is being thrown somehow and escaping from your OnUnhandledException handler? This could cause unusual behavior.

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

     

    Thursday, April 15, 2010 10:52 PM
  • It may depend on the specific exception type/origin.

    If the exception is a 'process state corrupted' type exception, normal unmanaged exception handlers will refuse to catch it. And probably so would the workflow runtime.

    For more info see:

    "Handling Corrupted State Exceptions" http://msdn.microsoft.com/en-us/magazine/dd419661.aspx 

    another special case, ThreadAbortException http://msdn.microsoft.com/en-us/library/system.threading.threadabortexception.aspx

    If you need isolation from process state corruption, you may need to consider running your workflow as a separate process.

    Tim

    Friday, April 16, 2010 5:37 PM
  • Hi,

     

    I experienced the same issue, after many tries, I found that if you set delegates for both Aborted and OnUnhandledException(return UnhandledExceptionAction.Abort;) then you will get the main thread exit. I'm not sure why but it seems in above special case, you should handle OnUnhandledException only

    Friday, August 19, 2011 7:23 AM