Your Cast.To() is just trying to interpret reference to given object as reference to T. Which fails of course.
And if compiler encounters (B) a and knows that a is of type A and type A has compile-time cast operator to type B - it emits this cast. It is not your case.