Just remembered this one. When running a VSMDI from the command line (using the mstest command switch /testmetadata) sometimes this error just happens - no help just 'specified cast is invalid'.
I found out a while ago that if you have test lists that are empty this error sometimes happens. What you do is go to the VSMDI editor in visual studio and in the VSMDI in question ensure that you either have tests in each Test List, or remove the test lists that are empty.
One more hassle from MSTest!!!!