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?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" <RaedSawalha@.discussions.microsoft.com> wrote in message
news:050B90D9-6524-46CD-BB20-E1FE3BAE0367@.microsoft.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?
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:RaedSawalha@.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?
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?
0 comments:
Post a Comment