T
TheSteph
Hi,
I have a small serializable struct :
[Serializable]
public struct TestStruct
{
public string Title;
public int Age;
public string Name;
public string Surname;
}
I "binary" Serialize it in a file without any problem.
I can desreialize it in the SAME application with NO problems.
But when I want to Deserialize it in an OTHER application, I get an Invalide
cast error :
TestStruct TmpTestStruct = (TestStruct)formatter.Deserialize(fs);
=> Error message "Specified cast is not valid" !
So, I tested to deserialize it in an object, and check the Type :
Object TmpObj = formatter.Deserialize(fs);
MessageBox.Show(TmpObj.GetType().ToString());
It works fine, and the MessageBox show "TestStruct". but impossible to cast
it as TestStruct !! ("Specified cast is not valid")
So why is it deserializable in the same Application and not in an other,
even if both use the same source ??
Can anybody help me ? Any idea of what I am doing wrong ? a MS Bug ? Is it
a problem because of different namesapce in both applications ?
Any help appreciated.
Steph.
I have a small serializable struct :
[Serializable]
public struct TestStruct
{
public string Title;
public int Age;
public string Name;
public string Surname;
}
I "binary" Serialize it in a file without any problem.
I can desreialize it in the SAME application with NO problems.
But when I want to Deserialize it in an OTHER application, I get an Invalide
cast error :
TestStruct TmpTestStruct = (TestStruct)formatter.Deserialize(fs);
=> Error message "Specified cast is not valid" !
So, I tested to deserialize it in an object, and check the Type :
Object TmpObj = formatter.Deserialize(fs);
MessageBox.Show(TmpObj.GetType().ToString());
It works fine, and the MessageBox show "TestStruct". but impossible to cast
it as TestStruct !! ("Specified cast is not valid")
So why is it deserializable in the same Application and not in an other,
even if both use the same source ??
Can anybody help me ? Any idea of what I am doing wrong ? a MS Bug ? Is it
a problem because of different namesapce in both applications ?
Any help appreciated.
Steph.