Hi,

I have inherited a project from a colleague and have an intersting problem. The project attempts to deserialize a type 'Client' into a new 'Client'.

Client mainClient = null;
using ( stream = File.Open(resourceFilePath, FileMode.Open))
                {
                    BinaryFormatter bin = new BinaryFormatter();                    
                    mainClient = (Client)bin.Deserialize(stream);
                }

this throws the error

"Unable to cast object of type 'Admin.Client' to type 'Client.Client'. "


I've read that deserializing via assemmblies (which this does) can lead to the objects being identified as completely different even if they are the same.

Having had no experience at all with this I was wondering if anyone could shed any light?

Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.