Invalid Length for Base-64 string problem

G

Guest

I have list of name separated by comm like this
name1,name2,name3,...etc
i converted then to Base-64 using Convert.ToBase64String() then pass them to
webmethod then i when try to get data back to original using
Convert.FromBase64String a crash generated with following error:

Invalid Lenght for Base-64 char array

what is the reason? the problem sometime code work and sometime it is crashed?
Is this a bug or what???
 
J

Jon Skeet [C# MVP]

Raed Sawalha said:
I have list of name separated by comm like this
name1,name2,name3,...etc
i converted then to Base-64 using Convert.ToBase64String() then pass them to
webmethod then i when try to get data back to original using
Convert.FromBase64String a crash generated with following error:

Invalid Lenght for Base-64 char array

what is the reason? the problem sometime code work and sometime it is crashed?
Is this a bug or what???

It sounds like it's probably a bug in your code. If it's not, you
should be able to produce a string x such that

Convert.FromBase64String(Convert.ToBase64String(x));

throws an exception. I'm sure if you can find such a string, MS would
be very keen on hearing about it.
 
J

Jon Skeet [C# MVP]

Jon Skeet said:
Well, you can convert that to and from base 64 with no problems, so it
must be something else going wrong.

Are you by any chance putting the base64-encoded string on a URL
afterwards? Base64 isn't "websafe" from what I remember.

Oh, and I meant to say - how are you converting the strings to a byte
array to start with?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top