473,246 Members | 1,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

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 9398
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Abby Lee | last post by:
My page runs fine...I just get the yeld sign with a "!" in it. Ok, I asked this question in the VBscript group and they tell me it's a JavaScript issue even though I don't get the error until I...
0
by: Riley Phelps | last post by:
When I use the XML Serializer in the following example, the first Serialize (with the class Pets) works, but the second (with the cplaa Pets2) fails. Which arrtubute nedds to be applied to make the...
5
by: schnell | last post by:
I'm getting an error that I'm very confused about. I'm trying to generate an XML file completely from scratch in code. Here is the code fragment that is causing me headaches: Dim mBOEDOC as...
3
by: Alejandro Penate-Diaz | last post by:
Hi. While trying to create a a word document in one of my asp.net pages I keep getting an ASP.NET permission error. first I thought it was been caused while trying to save the document, and I added...
0
by: utkarsh | last post by:
Hi All, I have a DLL contains two classes, first one which is to be serialized and other one is a UserControl class have code to serialize as below:- class XYZ:...
8
by: Thirsty Traveler | last post by:
I have a WebMethod as follows: public XmlDocument OrderContract(XmlDocument doc) { return OrderBLL.OrderContract(doc); } However, the client is generating a compile error when the...
0
Sakalicek
by: Sakalicek | last post by:
Hi all, I have following problem in my application. I have Web Service and project which uses methods from this Web Service. I created proxy WsProxy by wsdl.exe and put it into that project. But...
2
by: rajuk | last post by:
Hi i have following code,when i execute this code i got unterminated string constant error.any javascript guru can you look into this please. raju /* The link details */ var links = new Array...
8
by: trappedIntoCode | last post by:
Hi Everyone, Here is a part of javascript code that works well in FF2 but shows above error in IE6 and error "missing name after . operator" . function...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.