开发者

Explicitly persist states in Workflow 4.0 rather than everything

开发者 https://www.devze.com 2023-01-03 15:48 出处:网络
I have ran into an issue with my SQL instance store attached to a WorkflowApplication that is running. When I exit my application I\'m calling an Unload() on the WF app to persist it. I didn\'t think

I have ran into an issue with my SQL instance store attached to a WorkflowApplication that is running. When I exit my application I'm calling an Unload() on the WF app to persist it. I didn't think about it during design time, but it does makes sense, it's persisting an arg that was passed in to the WorkflowApplication constructor when instanced.

When the application runs, everything in the workflow works as expected. When I call Unload() I get an unhandled exception that states that the arg is not serializable and needs [DataContractAttribute].

What's passed into the workflow is my applications custom logger object that I wrote so that the WF can log to disk in a uniform way that I prefer. How do I prevent the 开发者_运维百科workflow app from persisting this one argument and persist everything else?

I'm sure something can be done with extensions but I'm having a hard time finding info on them or finding persistence examples for my scenario.


You can decorate the variable to not be serialised, with a [NonSerialized] attribute.

That should do the trick, it worked for me in a WF3.5 app. See http://msdn.microsoft.com/en-us/library/ms973893.aspx, heading "Selective Serialization"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号