I was calling a BinaryFormatter object's methods and getting an Invalid Cast exception.
That should have meant that I was trying to convert an object from one data type to an
incompatible data type, but I was assigning the returned result to an object of the
correct type.
After much head scratching, I discovered that I was passing the method an argument of the
wrong type. The development environment (Beta 2) thought the type was ok but the
BinaryFormatter couldn't handle it.
Moral: If you get an Invalid Cast exception, look first at the type of the variable to
which you are assigning the result. Then look at the type of the object you are passing
into the routine.
|