Efy wrote:
> Hello all,
>
> I have met something pretty odd.
> I am running a serialization on an object and not always the size of
> the output stream is the same.
> I even created a test that I am running the serialization in a loop,
> and each time I am running I have different results sizes in some
> point in the loop.
> This happens when I am using a object that was filled in the server
> side, and I get them thru WCF - working with NHibernate DAL, but the
> code is running on the client.
> Here is some of the code I am using for the loop:
> AAAA aaa = new AAAA();
> aaa.NewMethod();
> AssistanceFileEntityBankAccount
> m_AssistanceFileEntityBankAccount=aaa.AFBE;
>
> long size = 0;
> MemoryStream ms = new MemoryStream();
> BinaryFormatter bf = new BinaryFormatter();
>
>
> var entity = new Student();
> entity.Num = 11123456;
> entity.AccountClosingDate =
> m_AssistanceFileEntityBankAccount.AccountClosingDate;
>
> //without this line, everything works!
> entity.AssistanceFileEntity =
> m_AssistanceFileEntityBankAccount.AssistanceFileEntity;
> for (int i = 0; i < 100; i++)
> {
>
> bf.Serialize(ms, entity);
> ms.Seek(0, SeekOrigin.Begin);
> Debug.WriteLine(ms.ToArray().ToString());
> if (i > 0 && size != ms.Length)
> {
> Debugger.Break();
> }
> else
> {
> size = ms.Length;
> }
> }
>
> Each time I stop in a different I, the values are not equal, Is this
> make sense??!
> Any Ideas will be appreciated.
>
> Thanks,
> Efy
>
>
>
Sorry, I can't reproduce your issue, but I had to make up class
definitions to get this to compile.
Given that entity should not change inside the loop, I can't see why the
serialization of it would change. Does the AssistanceFileEntity property
get changed by some other object while the loop is running?
--
Mike
|