Windows Workflow Foundation NullReferenceException
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以检查一下此链接是否有帮助吗?
http://www.mono-project.com/Gendarme.Rules.Concurrency# ProtectCallToEventDelegatesRule
May you check if this link helpful?
http://www.mono-project.com/Gendarme.Rules.Concurrency#ProtectCallToEventDelegatesRule
您可能会因多种原因而得到上述异常,详细信息您需要检查内部异常属性,
其中一个可能的原因可能是,在超时时您可能希望从状态 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
您应该检查内部异常以获取更多详细信息。 检查事件服务类是否标记为 [Serialized],并在事件参数中将 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.
Check if this fixes the problem.
Thanks.