According to this newsgroup posting, Changing a namespace causes errors when using "BinaryFormatter.Deserialize" to reload object data saved while defined under a different namesapce(sic), you should look at the SerializationBinder class.
However, I would urge you to find a different way of handling your data, as the binary formatter is meant to be used as a short-lived transport packaging handler, not a storage handler.
Have you looked at protocol buffers, as an example?
Edit: Ok, after reading your comment, and re-reading your question, it turns out your question has nothing to do with serialization after all, binary or otherwise.
The problem, apparently, is that you've serialized a class of type A, and try to deserialize it, or cast it after deserialization, to type B, a different type.
This will of course not work right out of the box, and can easily be reproduced without introducing serialization at all, you simply do this:
public class A { ... } <-- a class with some properties and stuff
public class B { ... } <-- another class, with the same properties and stuff
public void Test()
{
A a = new A();
B b = a; <-- you get the same problem as in your code here
}
There are many ways to handle this. For instance, you can implement casting operators into one of the classes, which would make the above code work.
You can implement a "cloner" type method, one that takes an object of type A, constructs a new object of type B, and copies over all the properties and stuff.
Note that XML serialization uses the type you give to it as its root type, which means you can serialize an object of type A, and deserialize it as an object of type B, provided you only give B to the serialization object when you intend to deserialize, and providing that this type has enough meta-data to look like an object of type A.
I have a control question to you, which might give us some idea of why you're trying to do this: Why can't you deserialize it as the original type and leave it at that? Why do you have to cast it?