473,408 Members | 2,477 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,408 software developers and data experts.

Deserialization Error

Hello,

I am trying to deserialize a very simply XML file and have the
following code to do it. When I run the code, I keep getting this
error: "An unhandled exception of type
'System.InvalidOperationException' occurred in system.xml.dll.
Additional information: There is an error in XML document (4, 2)."

The thing I don't get is that this code is used for other XML files in
the department just fine and as far as I can tell there is nothing
wrong with my XML. It validates just fine. Does anyone know what this
is telling me? What does the 4,2 mean?

FileStream fileStream = null;
XmlTextReader xmlReader = null;
Holiday_List _dataMap;

try
{
string file = Path.Combine(Directory.GetCurrentDirectory(),
"HolidayInfo.xml");
fileStream = new FileStream(file, FileMode.Open);
xmlReader = new XmlTextReader(fileStream , XmlNodeType.Document,
null);
XmlSerializer serializer = new XmlSerializer(typeof(Holiday_List));
_dataMap = (Holiday_List)serializer.Deserialize(xmlReader );
return _dataMap;
}
finally
{
if (fileStream != null)
{
fileStream.Close();
}
if (xmlReader != null)
{
xmlReader.Close();
}
}

Mar 20 '06 #1
4 2972
Have you defined the Holiday_List class?

If so can you post it.

Dickster

Mar 20 '06 #2
Post the XML as well

Mar 20 '06 #3
There should be an innerexception with more detail (when the exception
occurs, click View detail, then expand to the InnerException property).

Post that also :) The 4,2 probably refers to where the error occured in
the text file

Mar 20 '06 #4
I got some help at work and figured it out. Holiday_List was the wrong
object to try to deserialize. There was another object called Holidays
which was the one I needed. I know that probably doesn't mean much to
anyone without seeing the schema on it, but that turned out to be the
problem. Thanks though!

Mar 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Serg | last post by:
Hi. I have a problem with deserialization decimal value. I have a simple class: public class A { public decimal d; } The serialization a value 0.00000001 is OK. The file is
2
by: Meta-Meta | last post by:
Hi, I'm trying to deserialize a VC++ .NET class and am stumped by the following problem : In order to create the XmlSerializer you need to pass the type of the object being created. The doc...
2
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data....
4
by: Mike Sarbu | last post by:
Hello all, I have an XML file like this: <?xml version="1.0" encoding="utf-8"?> <SomeObject xmlns="http://www.abcinc.com/objectdefinition"...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
0
by: Miguel RS | last post by:
Hi all, I have a winforms app (app1), a webservice (ws1) and a webpage (wp1). The webservice exposes a type (type1). When I generate a proxy (px1) for app1 I get the type ws1.type1. The thing is...
0
by: =?Utf-8?B?UGllcmNlQnJvc25hbg==?= | last post by:
I am using C#(Vs.Net 2003) The error I am getting is... System.Xml.XmlException: This is an unexpected token. The expected token is 'EndElement' I have come to understand that this error is...
1
by: Kapps | last post by:
Hi, I was wondering how I would go about deserializing a file that was serialized from a different project. I've tried a couple things, but I can't really seem to figure it out. When looking it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.