Continuing the adeventures with SharedVariables as part of Dynamics CRM plugins, I came across an odd one. As per general best practices for data transfer between components, it was decided to create a custom object as the Data Transfer Object (DTO) between various plugins. It was all working well in the unit tests, but as soon as it was deployed into the CRM server, it didn’t work, and threw very weird errors.

After much research done by a colleague (I was pre-occupied with other things), it was uncovered that the DTO caused the mess. By switching that to an Entity and using the Attributes as a key-value pair structure, we managed to get around it. After thinking about the issue it kind of made sense. Dynamics CRM would serialise the SharedVariables collection into XML and pass that to the next plugin in the execution pipeline. Because CRM couldn’t locate the relevant type for the DTO when deserialising, the error was thrown.

This could’ve been fixed it by tossing the relevant assembly with the required types into the GAC, but that’s generally bad practise and obviously impossible with CRM Online.

I’m just happy that it was fixed! Another issue resolved.