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

XML Serialization : Error reflecting field....

I have to deserialize an XML document to objects and then serialize it back to XML to pass to the stored proc.
I am attaching partial code. After this , I also have to serialize

Here is the XML :
<data>
<orders>
<order>
<order_id>0</order_id>
<issue_id>4460</issue_id>
<action>add</action>
</order>
</orders>
</data>

This is the main.cs file where I call the Deserializer
public class Main
{

public void AcceptOrdersDom( string strInputXML )
{

OrderRootDeSerialize ordRoot =(OrderRootDeSerialize) DeserializeObject(typeof(OrderRootDeSerialize), strInputXML );

}
protected object DeserializeObject(Type t, string xml)
{
MemoryStream memStream = new MemoryStream();
StreamWriter writer = new StreamWriter(memStream, System.Text.Encoding.ASCII);
writer.Write(xml);
writer.Flush();
memStream.Seek(0, 0);
XmlSerializer xs = new XmlSerializer(t);
return xs.Deserialize(memStream);
}
}

And this the class type of which i have to deserialize.

namespace Sandeep.Test
{

[XmlRoot("data", IsNullable = false)]
public class OrderRootDeSerialize
{
public OrderRootDeSerialize ()
{}

[XmlArray("orders")]
[XmlArrayItem("order")]
public DeSerializeOrders[] ords ;

}

// Order Base Class
public class Orders
{

public Orders()
{}

#region Member Variables
protected int _orderId;
protected int _issueId;
protected string _action;
#endregion

#region Public Properties
public int OrderId
{
get { return _orderId; }
set { _orderId = value ; }
}

public int IssueId
{
get { return _issueId; }
set { _issueId = value; }
}

public string Action
{
get { return _action; }
set { _action = value; }
}
}

public class DeSerializeOrders : Orders
{
public DeSerializeOrders()
{}

[XmlElement("order_id")]
new public int OrderId
{
set { base.OrderId = value ; }
}

[XmlElement("issue_id")]
new public int IssueId
{
set { base.IssueId = value; }
}

[XmlElement("action")]
new public string Action
{
get { return base.Action ; }
set { base.Action = value; }
}

}
}

It compiles fine. When I run it it gives me an error back saying
"There was an error reflecting field 'ords'."

I have been trying to figure it out but no luck . Can somebody please help me
Nov 12 '05 #1
0 1915

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

Similar topics

3
by: Mark | last post by:
Hello, What I am trying todo is use .NET serialization to take a Guid property that is an attribute in the XML document and have its output to be the same as...
0
by: DotNetJunkies User | last post by:
I have to deserialize an XML document to objects and then serialize it back to XML to pass to the stored proc. I am attaching partial code. After this , I also have to serialize Here is the XML :...
0
by: Dave Veeneman | last post by:
I'm using XML Serialization on a class hierarchy headed by a Project Class. When I attempt to serialize, I get an InvalidOperationException from system.xml.dll with the explanation that there was...
0
by: Reader | last post by:
Why would this fail? When i rename the ProgramType to say.. ProramType it works.. but if it is ProgramType the following error occurs. An unhandled exception of type...
5
by: Arjen | last post by:
Hello, Can somebody help me a little bit? I can't get it to work. Please see my code below... I have placed some comments like "// And whats next?". I'm sure that I have to code something...
5
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
0
by: CJ Taylor | last post by:
hey everyone, thought I would ask this here because the web service groups seems pretty light on conversation. I'm buliding a web service, but keep getting this error. I understand the error,...
3
by: Paulo Morgado [MVP] | last post by:
Hi all ..NET Framework 1.1 I have created several types that are serailized to XML as strings. Someting like this: public struct MyInt32 : IXmlSerializable { int value;
0
by: Craig Vermeer | last post by:
Hi all, I'm hoping that someone has seen this before. I wasn't able to find any solutions through my usual channels (I.E Google). I'm getting the following exception in certain situations...
4
by: mijalko | last post by:
Hi, I have inherited my class from System.Drawing.Printing.PrintDocument and I wish to serialize this object using XmlSerializer. And I get exception "There was an error reflecting type ...". If I...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.