XMLReader exception - possible .NET2003 bug. 
Author Message
 XMLReader exception - possible .NET2003 bug.

We've just upgraded to VS .NET 2003, and some functionality in one of our
applications has started throwing an exception.

We have a bit of code that serialises a whole load of stuff using SOAP:

****************************************************************************
*******

public override object EditValue( ITypeDescriptorContext context,
IServiceProvider provider, object value )
{
CTHSave save = value as CTHSave;
if ( save != null )
{
CTHAsphericProxyBase parent = save.Parent;
if( parent.SaveFileDialog.ShowDialog() == DialogResult.OK )
{
Stream saveStream = null;
try
{
saveStream = parent.SaveFileDialog.OpenFile();
if ( null != saveStream )
{
// Save the Coefficients
SoapFormatter soapFormatter = new SoapFormatter();
soapFormatter.Serialize( saveStream, parent.A01 );
soapFormatter.Serialize( saveStream, parent.A02 );
soapFormatter.Serialize( saveStream, parent.A03 );
soapFormatter.Serialize( saveStream, parent.A04 );
soapFormatter.Serialize( saveStream, parent.A05 );
soapFormatter.Serialize( saveStream, parent.A06 );
soapFormatter.Serialize( saveStream, parent.A07 );
soapFormatter.Serialize( saveStream, parent.A08 );
soapFormatter.Serialize( saveStream, parent.A09 );
soapFormatter.Serialize( saveStream, parent.A10 );
soapFormatter.Serialize( saveStream, parent.A11 );
soapFormatter.Serialize( saveStream, parent.A12 );
soapFormatter.Serialize( saveStream, parent.A13 );
soapFormatter.Serialize( saveStream, parent.A14 );
soapFormatter.Serialize( saveStream, parent.A15 );
soapFormatter.Serialize( saveStream, parent.A16 );
soapFormatter.Serialize( saveStream, parent.A17 );
soapFormatter.Serialize( saveStream, parent.A18 );
soapFormatter.Serialize( saveStream, parent.A19 );
soapFormatter.Serialize( saveStream, parent.A20 );
soapFormatter.Serialize( saveStream, parent.BaseRadius );
soapFormatter.Serialize( saveStream, parent.ConicConstantK );
soapFormatter.Serialize( saveStream, parent.IsShapeConcave );

Quote:
}
}

catch( Exception exception )
{
Debug.Assert( false, exception.ToString() );
CTHDiagnostics.Instance().LogException( exception );
Quote:
}

finally
{
// Must close the stream
saveStream.Close();

Quote:
}
}
}
return value;
}

***************************************************************************

And we have some code to deserialise it:

***************************************************************************

public override object EditValue( ITypeDescriptorContext context,
IServiceProvider provider, object value )
{
CTHOpen open = value as CTHOpen;
if ( open != null )
{
CTHAsphericProxyBase parent = open.Parent;
if( parent.OpenFileDialog.ShowDialog() == DialogResult.OK )
{
Stream openStream = null;
try
{
openStream = parent.OpenFileDialog.OpenFile();
if ( null != openStream )
{
// Open the coefficients
SoapFormatter soapFormatter = new SoapFormatter();
parent.A01 = ( double )soapFormatter.Deserialize( openStream );
parent.A02 = ( double )soapFormatter.Deserialize( openStream );
parent.A03 = ( double )soapFormatter.Deserialize( openStream );
parent.A04 = ( double )soapFormatter.Deserialize( openStream );
parent.A05 = ( double )soapFormatter.Deserialize( openStream );
parent.A06 = ( double )soapFormatter.Deserialize( openStream );
parent.A07 = ( double )soapFormatter.Deserialize( openStream );
parent.A08 = ( double )soapFormatter.Deserialize( openStream );
parent.A09 = ( double )soapFormatter.Deserialize( openStream );
parent.A10 = ( double )soapFormatter.Deserialize( openStream );
parent.A11 = ( double )soapFormatter.Deserialize( openStream );
parent.A12 = ( double )soapFormatter.Deserialize( openStream );
parent.A13 = ( double )soapFormatter.Deserialize( openStream );
parent.A14 = ( double )soapFormatter.Deserialize( openStream );
parent.A15 = ( double )soapFormatter.Deserialize( openStream );
parent.A16 = ( double )soapFormatter.Deserialize( openStream );
parent.A17 = ( double )soapFormatter.Deserialize( openStream );
parent.A18 = ( double )soapFormatter.Deserialize( openStream );
parent.A19 = ( double )soapFormatter.Deserialize( openStream );
parent.A20 = ( double )soapFormatter.Deserialize( openStream );
parent.BaseRadius = ( double )soapFormatter.Deserialize( openStream );
parent.ConicConstantK = ( double )soapFormatter.Deserialize( openStream );
parent.IsShapeConcave = ( bool )soapFormatter.Deserialize( openStream );
open.FileName = Path.GetFileNameWithoutExtension(
parent.OpenFileDialog.FileName );

Quote:
}
}

catch( Exception exception )
{
Debug.Assert( false, exception.ToString() );
CTHDiagnostics.Instance().LogException( exception );
Quote:
}

finally
{
// Must close the stream
openStream.Close();

Quote:
}
}
}
return value;
}

***************************************************************************

When deserialising, it gets so far down the list of doubles, then throws
this exception:

System.Xml.XmlException
{"The data at the root level is invalid. Line 63, position -464." }

Now, I've inspected the document in question, I'm no XML parser, but it
looks ok.

What's more interesting, is that I can read the same file with no problems
into a build of the application that was built with v2002 of VS. So it seems
that the XMLWriter hasn't changed, but the XMLReader is behaving
differently.

Any help would be greatly appreciated.

Regards,

4Space



Mon, 17 Oct 2005 16:57:32 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. REPOST: Multiple drive BUG VS.NET2003 with absolute IntDir/OutDir path

2. Multiple drive BUG VS.NET2003 with absolute IntDir/OutDir path

3. VC exception bug or bug in my code?

4. Possible exceptions and Xml comments

5. How to convert content of XmlReader to a String

6. XmlReader!

7. MemberwiseClone XmlReader

8. unmanaged classes now public in VS.NET2003

9. .NET2003 Features

10. .Net2003 struct strangeness

11. Possible bug with Bitmap(string) constructor?

12. ThreadPool possible bug? [NUnit test included]

 

 
Powered by phpBB® Forum Software