[Mono-list] BinaryFormatter, Deserialize(), casting throws exception.

Atsushi Eno atsushi at ximian.com
Tue Aug 29 05:26:24 EDT 2006


Hi,

I'm not expertized in remoting land so I'm not writing the solution,
but anyways ... this InvalidCastException is likely to happen in
remoting land and in that case it is also likely to happen that
those types are regarded as identical, while one is a transparent
proxy while the other is the original type.

Another thought I have is that the InvalidCastException might not
be happening against "Mydata" type but somewhere inside the
deserialization. What does the full stack trace tell you?

Atsushi Eno

Robert Jordan wrote:
> Wiktor Grębla wrote:
>> Robert Jordan napisał(a):
>>
>>> Because the deserialized data is not of type "Mydata".
>>> What's the output of
>>>
>>> Console.WriteLine (bf.Deserialize(fs).GetType ().FullName)
>>>   
>> Mydata (unfortunately).
> 
> It could be another version of Mydata.
> 
> Try
> 
> Console.WriteLine (bf.Deserialize(fs).GetType ().Assembly.FullName)
> 
> and
> 
> Console.WriteLine (typeof (Mydata).Assembly.FullName)
> 
> 
> BTW, try to get a *full* stack trace using
> 
> try {
> 	your code
> } catch (Exception ex) {
> 	Console.WriteLine (ex);
> }
> 
> Robert
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list