Thursday, January 16, 2003

SoapFormatter chokes on some strings

It seems that SoapFormatter has a problem encoding strings.

If you have a string that contains a character with a value between 0x1 and 0x1F, SoapFormatter will not encode that character when writing the resulting XML, but will then puke when reading it.

Here's the code that demonstrates the problem. The call to Deserialize in the last line of the function below will throw an exception.

void Test () {
string s = "\x01";
MemoryStream stream = new MemoryStream();
IFormatter formatter = new SoapFormatter();
formatter.Serialize(stream, s); stream.Seek (0, SeekOrigin.Begin); string q = (string)formatter.Deserialize(stream); }

I've added this bug to the .NET Bugs Registry.

Many thanks to Hugh Brown who reported being bitten by this one when using Composite.

   11:18 PM

Content of this site is © Dejan Jelovic. All rights reserved.