From: Joe Cool on
On Sep 23, 10:12 pm, Family Tree Mike
<FamilyTreeM...(a)ThisOldHouse.com> wrote:
> Joe Cool wrote:
> > On Sep 23, 3:56 pm, "Peter Duniho" <no.peted.s...(a)no.nwlink.spam.com>
> > wrote:
> >> On Wed, 23 Sep 2009 13:51:01 -0700, Joe Cool <joecool1...(a)live.com> wrote:
> >>>> Here are some links you may find  
> >>>> helpful:http://www.yoda.arachsys.com/csharp/complete.htmlhttp://www.yoda.arac...
> >>>> Java-centric stuff, but mostly applicable to any  
> >>>> programming questions)
> >>> Interesting reading. But none of it answers my original question.
> >> Correct.  The goal of those links are not to answer your original  
> >> question, but to provide you with the information you need in order to ask  
> >> a question that can be answered.
>
> > I am still missing your point. From what I can tell, the only problem
> > with what I posted was that I included a bunch on comments in the
> > Generic Binder class post. But jeez, how does that mean that I have
> > asked a question that cannot be answered.
>
> > You asked for more details, I provided them. What's the problem?
>
> I believe the point is that it may help if you show a main subroutine
> that 1) creates the object, 2) serializes it, and 3) deserializes it.
> One reason being is, that with the following, I don't observe what you
> are asking about.
>
>          public static void Main(string [] args)
>          {
>              Attachment a = new Attachment();
>              BinaryFormatter bf = new BinaryFormatter();
>              MemoryStream ms = new MemoryStream();
>              bf.Serialize(ms, a);
>              ms.Seek(0, SeekOrigin.Begin);
>
>              Attachment b;
>              b = (Attachment) bf.Deserialize(ms);
>              Console.WriteLine("Done");
>              Console.ReadKey();
>          }
>

Yes, I understand's Peter's criticism now. Since I did not want to
post any company proprietary code I wrote a console app to demonstrate
the problem and lo and behold, it worked fine.

Turns out I was depending on some third party software to properly
store the byte array in a database and return it to me in its original
format. But they were not storing the very last byte. Their software
returned to me the correct number of bytes but the last byte was now
zero instead of the value I was expecting it to be.

Lesson learned: don't assume third party software is going to work as
you expect it to.