简体   繁体   English

Windows Workflow Foundation NullReferenceException

[英]Windows Workflow Foundation NullReferenceException

I got a NullReference problem using WWF and externaly raised events. 我使用WWF和外部引发事件遇到了NullReference问题。 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. WWF状态机与服务实例一起在状态机中引发事件,以提供数据,当然也可以更改状态。 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. 使用有效的向导创建ExternalDataEventArgs。 The Excetion is raised accessing the delegate within the event: 在事件中访问代理时引发Excetion:

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. 谢谢。

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 一个可能的原因可能是我超时后可能要从状态A转换到状态B,但是在状态更改之前,您需要验证自己是否确实处于状态A

POST THE INNER Exceptions detials for clarity 张贴内部异常细节以求清楚

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. 检查事件服务类是否标记为[Serializable],并在事件args中还将WaitForIdle属性设置为true。

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

Check if this fixes the problem. 检查是否可以解决问题。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM