I am trying to figure out how to access a stack trace when a Fault Handler is invoked in Windows Workflow 3.5. The fault handler is hooked up to the following function:
private void onGeneralFault(object sender, EventArgs e)
but I am having troub开发者_开发技巧le finding how to get to the exception that leads to this. The fault handlers container has a Fault object but that seems to be set to null when I step through the code in the debugger. Also, there is an individual "Fault" property in the workflow designer in Visual Studio for the individual fault handler, but this is greyed out, so I cannot set it.
I figured it out. These casts are not the prettiest thing, but this is what I ended up doing:
private void onGeneralFault(object sender, EventArgs e)
{
CodeActivity thisActivity = (CodeActivity)sender;
Exception exception = ((FaultHandlerActivity)thisActivity.Parent).Fault;
...
Any better solutions are welcome.
精彩评论