Friday, November 28, 2008

Type 'Microsoft.SharePoint.SPListItem' is not marked as serializable."

I was creating one SharePoint sequential workflow which will create a task and will be in "InProgress" status until the task is completed. But while changing the task i was seeing a weired behaviour of the workflow. It completed automatically with "Completed" status even though the task is not marked as completed. It also logged an error in the workflow history list which was not actually gave me any clue to proceed further. Following was the error message..

"Type 'Microsoft.SharePoint.SPListItem' in Assembly 'Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' is not marked as serializable."

After checking the code inside the "OnTaskChanged" activity. I tried the following code change.

Commented the below explicit variable declaration
//private SPListItem taskValue;

Changed the below line from
taskValue = workflowProperties.Web.Lists["Tasks"].GetItemById(onTaskChanged1_AfterProperties1.TaskItemId);
To
SPListItem taskValue = workflowProperties.Web.Lists["Tasks"].GetItemById(onTaskChanged1_AfterProperties1.TaskItemId);

It resolved my problem. But don't know yet what the above error is meant to be. I think i am missing some basic understanding here. Still working on it :)

No comments: