Re: xml serialization of List<byte>

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



If you want an array of bytes serialized as Base64, use an array, not a
List.

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

The devil is in the yada yada yada


<lee.crabtree@xxxxxxxxx> wrote in message
news:1162413539.934521.278220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm trying to serialize a generic List of bytes, as in List<byte>. Out
of the box, it works, but it winds up like this:

...
<LineData>0</LineData>
<LineData>0</LineData>
<LineData>0</LineData>
<LineData>0</LineData>
<LineData>0</LineData>
<LineData>0</LineData>
<LineData>0</LineData>
<LineData>255</LineData>
<LineData>255</LineData>
<LineData>255</LineData>
<LineData>255</LineData>
<LineData>255</LineData>
<LineData>255</LineData>
...

The data is right, but have each byte in a tag is just asinine. It
would make a whole lot more sense to have it serialized as "hexBinary"
or "base64Binary", but adding those attributes throw an error saying
that there was an exception reflecting the type containing the List.

What am I doing wrong?

Lee Crabtree



.



Relevant Pages

  • Re: How to verify specified signature in .NET using RSA
    ... why are you converting the signed token provided as Base64 into a byte array and then back into a string and then back into a byte array again instead of converting it directly to a byte array as I suggested? ... It seems less likely to be the right way to this since the signature data is probably arbitrary binary data which would encode properly as Base64 but might not have a valid string representation in ASCII since ASCII allows a much reduced set of characters and will not deal well with unprintable values and nulls. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Encrypted email - is there a specific solution?
    ... assign the byte array to the mailmsg body please? ... >, then you can encrypt ... > the data and either send it to yourself as an attachment or base64 encode it ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: displaying binary images
    ... It is a base64 byte array of the format of a png file. ... disk as a png file with that extension, it opens fine in the browser. ...
    (comp.lang.javascript)
  • Re: Base64 strange problem
    ... base64 decoder in the servlet to decode it. ... the decoded byte array is shorter then the original one. ...
    (comp.lang.javascript)
  • Re: Are constants not locally static?
    ... array length of the value it's allowed (but not compliant, ... yada yada ... ... So onto the code that caused the warning. ... The package is ...
    (comp.lang.vhdl)