Cast exception (rebased onto develop)



This is the same as gh-2630 but rebased onto develop.

----

Do not cast object.
See https://trac.openmicroscopy.org.uk/ome/ticket/12374

The problem is difficult to reproduce see ticket for details.