We recently noticed custom code on Dynamics 365 (CRM 8.2) environments threw a “System.AggregateException: One or more errors occurred.” instead of the usual IPluginException we want to display to the end user.

First we did some initial tests to figure out what was happening.
Then we created a simple plugin-assembly and workflow-assembly which only does one thing.
It throws an InvalidpluginExecutionException which should display “Hello Dynamics 365 custom error message” as the exception message rather then System.AggregateException.

System.AggregateException test code

First the workflow code:

Second the plugin code:

Last but not least the System.AggregateException message:

Results and thoughts

After testing a number of combinations, a pattern started to show.
Only the code activity assemblies that are running in the sandbox seemed affected.
Same result for CRM online as on premise.


Workflow async Workflow sync Plugin Plugin async Action
No isolation OK OK OK OK OK


I guess that the 8.2 release of CRM (Dynamics 365) brings some kind of parallel.foreach functionality in to the asynchronous sandbox processing engine. Currently I haven’t found any way around it.

We can catch the aggerate exception and handle it, but that doesn’t give us the possibility to display an appropriate message to the end user.

If you did find a solution, don’t hesitate and leave a comment on how to tackle this problem.