469,625 Members | 1,564 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

There was an error generating the XML document.

Hello when I serialize an object an error generated using this function
public string SerializeObject(object oClassObject,System.Type oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}

and exception occured with message "There was an error generating the XML
document."
how can I know where is the error occured the stack trace did not give usef
info

StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133" string

line 133 where I called oSerializer.Serialize(writer,oClassObject);

Any Suggestions?
Nov 19 '05 #1
3 8989
And that's all the stack trace? There isn't anything more in the error
description (no description of inner exception whatsoever)?

I think you'd get replies faster by asking this at
microsoft.public.dotnet.xml group (I sent this to that group).

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.com...
Hello when I serialize an object an error generated using this function
public string SerializeObject(object oClassObject,System.Type oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}

and exception occured with message "There was an error generating the XML
document."
how can I know where is the error occured the stack trace did not give
usef
info

StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133" string

line 133 where I called oSerializer.Serialize(writer,oClassObject);

Any Suggestions?

Nov 19 '05 #2
Can you post the definition of the class you're trying to serialize?

If the class is not serializable, the XmlSerializer is going to have a
hard time turning it into an XML document :)

Greetings,
Wessel

-----Original Message-----
From: Raed Sawalha [mailto:Ra*********@discussions.microsoft.com]
Posted At: Sunday, April 10, 2005 11:25 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: There was an error generating the XML document.
Subject: There was an error generating the XML document.

Hello when I serialize an object an error generated using this function
public string SerializeObject(object oClassObject,System.Type
oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}

and exception occured with message "There was an error generating the
XML
document."
how can I know where is the error occured the stack trace did not give
usef
info

StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces, String encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object
o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter,
Object o)\r\n at Test.Form1.SerializeObject(Object oClassObject, Type
oClassType) in d:\\scorm\\test\\form1.cs:line 133" string

line 133 where I called oSerializer.Serialize(writer,oClassObject);

Any Suggestions?

Nov 19 '05 #3
Hello Raed,

Your code looks ok. You'll need to dig down into the InnerException ... buried
down in there you'll find the root cause of the problem.

--
Matt Berther
http://www.mattberther.com
Hello when I serialize an object an error generated using this
function
public string SerializeObject(object oClassObject,System.Type
oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new
System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
try
{
oSerializer.Serialize(writer,oClassObject);
}
catch(InvalidOperationException ex)
{
string msg = ex.Message;
string stack = ex.StackTrace;
}
return strBuilder.ToString();
}
and exception occured with message "There was an error generating the
XML
document."
how can I know where is the error occured the stack trace did not give
usef
info
StackTrace : " at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String
encodingStyle)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
textWriter, Object o, XmlSerializerNamespaces namespaces)\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(T extWriter
textWriter, Object o)\r\n at Test.Form1.SerializeObject(Object
oClassObject, Type oClassType) in d:\\scorm\\test\\form1.cs:line 133"
string

line 133 where I called oSerializer.Serialize(writer,oClassObject);

Any Suggestions?

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alejandro Penate-Diaz | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.