views:

43

answers:

2

Hi,

I have a workflow service which receives a stream through a ReceiveRequest activity.

The workflow works well, but if I try to persist it I have an exception (Cannot access a closed stream) which I think is related to the stream object.

The object received is similar to this:

public class MessageContext
{
public Stream Content{get;set;}
//..other properties
}

and the object sent is a MemoryStream (which is added to Known service types).

Anyone can help me?

+1  A: 

All your data in the workflow needs to be of a serializable type. A stream isn't so read the data from the stream and save if getting rid of the stream as soon as possible.

Maurice
This is what I did, saving the stream and set the property to null before the persist activity, but I'm receiving the error anyway.
fra
+1  A: 

If you're persisting your workflow, you want to make sure all your variables are serializable. I've had to refactor a previous workflow to do this, or make sure any non basic objects were set to null before the workflow could idle.

I prefered just sending basic types after that, setting variables to null just didn't feel right.

dmelinosky