Fix issue 1563: on mono this code behaves different and causes a null reference exception