Windows Workflow Foundation NullReferenceException

发布于 2024-07-13 19:01:33 字数 880 浏览 5 评论 0原文

我使用 WWF 和外部引发的事件遇到了 NullReference 问题。 WWF 状态机与在状态机中引发事件的服务实例一起工作,以提供数据,当然还可以更改状态。 虽然“正常”操作使用事件工作正常,但我遇到了一个奇怪的问题。

为了处理超时场景,我让状态初始值设定项使用外部超时机制在提到的服务中注册回调。 在给定时间之后,回调函数运行并应在状态机中引发超时事件。 事件定义如下:

event EventHandler<ExternalDataEventArgs> DeviceSysmapBrdcstTimeoutEvent;

如上所述,如果不从超时机制调用,则可以正常工作。 ExternalDataEventArgs 是使用有效的 Guid 创建的。 在事件中访问委托会引发异常:

System.Workflow.Activities.EventDeliveryFailedException was unhandled by user code
    Message="Event \"DeviceSysmapBrdcstTimeoutEvent\" on interface type \"...\" for instance id \"efa3da3d-8546-4fcf-bc56-bbec04df6d69\" cannot be delivered."
Source="System.Workflow.Activities"
    StackTrace:
        at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)

有人有想法吗? 谢谢。

I got a NullReference problem using WWF and externaly raised events. The WWF state machine works together with a service instance raising events in the state machine to provide data and - of course - to change the state. While the "normal" operation works fine using events I got a strange problem.

To handle timeout scenarios I let the state initializer use a external timeout mechanism to register a callback in the menioned service. After the given time the callback function runs and shall raise the timeout event in the state machine. The events are defined like this:

event EventHandler<ExternalDataEventArgs> DeviceSysmapBrdcstTimeoutEvent;

and as mentioned work properly if not called from the timeout machanism. The ExternalDataEventArgs are created using valid Guids. The Excetion is raised accessing the delegate within the event:

System.Workflow.Activities.EventDeliveryFailedException was unhandled by user code
    Message="Event \"DeviceSysmapBrdcstTimeoutEvent\" on interface type \"...\" for instance id \"efa3da3d-8546-4fcf-bc56-bbec04df6d69\" cannot be delivered."
Source="System.Workflow.Activities"
    StackTrace:
        at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)

Anyone an idea? Thanks.

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

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

发布评论

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

评论(3

梦情居士 2024-07-20 19:01:33

您可能会因多种原因而得到上述异常,详细信息您需要检查内部异常属性,

其中一个可能的原因可能是,在超时时您可能希望从状态 A 转换到状态 B,但在状态更改之前,您需要验证您是否处于状态更改状态。实际上处于状态 A

POST THE INNER Exceptions 详细信息以便清楚起见

you may get the above exception for several reasons for details you need to check the Inner exceptions property

one possible reason might me that on time out you might want to transition from state A to State B but before state change you need to verify that you are actually in state A

POST THE INNER Exceptions detials for clarity

倾其所爱 2024-07-20 19:01:33

您应该检查内部异常以获取更多详细信息。 检查事件服务类是否标记为 [Serialized],并在事件参数中将 WaitForIdle 属性设置为 true。

CustomEventDataArgs eventArgs = new CustomEventDataArgs();
//
eventArgs.WaitForIdle = true;

检查这是否可以解决问题。

谢谢。

You should check the inner exception for more details. Check if you event service classes are marked [Serializable] and also set the WaitForIdle property to true in the event args.

CustomEventDataArgs eventArgs = new CustomEventDataArgs();
//
eventArgs.WaitForIdle = true;

Check if this fixes the problem.

Thanks.

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