views:

49

answers:

1

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.

+1  A: 

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"

Joon
Ok I was applying attributes incorrectly. In my Logger class I decorated it with [Serializable] (even though I don't like that implementation since it's not supposed to be serialized in the first place) and then marked the instantiated Logger object with [NonSerialized]. Now persisting ignores the logger object. Thanks Joon!
jlafay