Windows Workflow Foundation 4 (WF4) 错误处理

发布于 2024-08-26 22:32:24 字数 119 浏览 4 评论 0原文

将错误消息从 WF4 工作流返回到托管 ASP.NET MVC 应用程序的最佳方法是什么?我需要工作流程不终止,但继续处于活动状态,然后将有关错误的消息传递回托管应用程序,以便用户可以采取替代操作,但我不确定如何执行此操作。

What is the best way to get error messages from a WF4 workflow back to a hosting ASP.NET MVC application? I need the workflow to not terminate, but continue to be active, and then pass a message back to the hosting app regarding the error, so the user can take an alternative action, but I'm not sure how to do that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

九局 2024-09-02 22:32:24

为了使您的工作流程保持活动状态,您需要捕获工作流程中的异常。将 TryCatch 活动添加到您的工作流中,并且在 Catch 块中,您可以使用 Send 或自定义活动将数据发送到主机应用程序。

一个例外是使用具有持久性的 WorkflowApplication.OnUnhandledException 并指定中止。在这种情况下,工作流的内存状态将被删除,并且可以重新加载工作流以获得最后的持久状态。如果您采用这种方式,则需要使用 Perist 活动确保每当无法重做的事情时都会保存您的工作流程。

In order to keep your workflow alive you need to catch the exception in your workflow. Add a TryCatch activity to you workflow and in a Catch block you can use either a Send or a custom activity to send the data to the host application.

The one exception is to use the WorkflowApplication.OnUnhandledException with persistence and specify abort. In that case the in memory state of the workflow is just removed and the workflow can be reloaded for the last persisted state. If you go this way you need to make sure, using the Perist activity, that your workflow is saved whenever something that cannot be redone.

暖心男生 2024-09-02 22:32:24

对于 WF4 来说,TryCatch 还不够。此外,处理来自工作流主机的 UnhandledException 事件并不能真正告诉您有关哪个活动失败以及失败的原因。

建议的方法是在 WF4 中使用 TryCatch 和活动跟踪。对此的一个很好的总结可以在这里找到: http://msmvps.com/blogs/theproblemsolver/archive/2009/11/27/trycatch-activity-in-wf4.aspx

您可以使用跟踪参与者和捕获处理程序来扩展您的工作流主机封装可能发生故障的活动、处理异常并创建一个新的 TrackingRecord 来更好地说明发生的情况。

TryCatch is not really enough when it comes to WF4. Also, handling the UnhandledException event from your workflow host doesn't really tell you much about which activity failed and why.

A suggested approapch is to use TryCatch and Activity tracking within WF4. A good summary of this can be found here: http://msmvps.com/blogs/theproblemsolver/archive/2009/11/27/trycatch-activity-in-wf4.aspx

You can extend your workflow host with Tracking participants and with a catch handler that encapsulates your activity that might fault, handle the exception and create a new TrackingRecord that can better illustrate what happened.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文