System.Runtime.Serialization.SerializationException- Sandbox Workflow

We recently encountered this error, while working on an existing CRM 2011 custom workflow to make it ready for CRM 2016 online. First we tested this workflow on CRM 2016 non-sandbox mode and it was working fine. But when we tried to deploy this workflow on sandbox mode we started getting following error:

“System.Runtime.Serialization.SerializationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #5E7698A3”

This error seems to be strange, as this is a serialization error and but why it was working fine on a non-sandbox mode. When we started doing troubleshooting and debugging code in sandbox mode, we found this error was coming because of the following line, as early bound classes were used in this workflow:

new ConditionExpression(“statecode”, ConditionOperator.Equal, HIMBAP.ProductState.Active);

To avoid this error, we changed this to following, just like it is used in late bound programming model:

new ConditionExpression(“statecode”, ConditionOperator.Equal, 0);

And workflow started working fine in sandbox mode as well.

Hope it will help someone !!

Leave a Reply

Your email address will not be published. Required fields are marked *