I'm trying to read a binary serialized object, that I don't have the object definition too. I took a peak into the file and saw property names, so I manually recreated the object (let's call it SomeDataFormat).
I ended up with this :
public class SomeDataFormat
{
public string Name{ get; set; }
public int Country{ get; set; }
public string UserEmail{ get; set; }
public bool IsCaptchaDisplayed{ get; set; }
public bool IsForgotPasswordCaptchaDisplayed{ get; set; }
public bool IsSaveChecked{ get; set; }
public string SessionId{ get; set; }
public int SelectedLanguage{ get; set; }
public int SelectedUiCulture{ get; set; }
public int SecurityImageRefId{ get; set; }
public int LogOnId{ get; set; }
public bool BetaLogOn{ get; set; }
public int Amount{ get; set; }
public int CurrencyTo{ get; set; }
public int Delivery{ get; set; }
public bool displaySSN{ get; set; }
}
Now I'm able to deserialize it like this :
BinaryFormatter formatter = new BinaryFormatter();
formatter.AssemblyFormat = FormatterAssemblyStyle.Full;
formatter.TypeFormat = FormatterTypeStyle.TypesWhenNeeded;
FileStream readStream = new FileStream("data.dat", FileMode.Open);
SomeDataFormat data = (SomeDataFormat) formatter.Deserialize(readStream);
First suspicious thing is that only the 2 string (SessionId&UserEmail) has value in the deserialized *data* object. The other properties are null or just 0. This might be intended, but still, I suspect that something has gone wrone during the deserialization.
The second suspicious thing is if I reserialize this object, I end up with different file sizes. Original (695bytes). Reserialized object is 698bytes. So there is 3bytes difference. I should get the same file size as the original.
Taking a look at the original, and the new (reserialized) file:
The originally serialized file.
The reserialized file.
As you can see, after the header section, the data appears to be in different order. For example, you can see that the email, and the sessionID is not at the same place.
Q1: Why are the values are in different order in the two files?
Q2: Why is there extra 3 bytes compared the 2 serialized objects?
Q3: What am I missing? How could I do this?
Any tipps/help appreaciated.