PC Review


Reply
Thread Tools Rate Thread

BinarySerialization size not consist?!

 
 
Efy
Guest
Posts: n/a
 
      6th Jul 2009
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



 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      6th Jul 2009
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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BinarySerialization size not consist?! Efy Microsoft Dot NET 1 6th Jul 2009 11:09 PM
BinarySerialization size not consist?! Efy Microsoft C# .NET 1 6th Jul 2009 11:09 PM
can I stop binary compatibility being enforced when using binaryserialization? Richy Microsoft VB .NET 0 23rd Dec 2008 06:04 AM
Where do I set the criteria for what passwords need to consist of? Kelvin Beaton Windows XP Security 1 14th Jan 2004 12:13 AM
i need to know in what consist the security bug RPC aekroft Windows XP Security 3 2nd Oct 2003 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 AM.