473,795 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>446 0</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 )
{

OrderRootDeSeri alize ordRoot =(OrderRootDeSe rialize) DeserializeObje ct(typeof(Order RootDeSerialize ), strInputXML );

}
protected object DeserializeObje ct(Type t, string xml)
{
MemoryStream memStream = new MemoryStream();
StreamWriter writer = new StreamWriter(me mStream, System.Text.Enc oding.ASCII);
writer.Write(xm l);
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 OrderRootDeSeri alize
{
public OrderRootDeSeri alize ()
{}

[XmlArray("order s")]
[XmlArrayItem("o rder")]
public DeSerializeOrde rs[] 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 DeSerializeOrde rs : Orders
{
public DeSerializeOrde rs()
{}

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

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

[XmlElement("act ion")]
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 1939

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

Similar topics

3
2364
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 Guid.NewGuid().ToString().ToUpper().Replace("-","") I have a working copy of this type of class that will work generating an element with the output i have and the following is an example of that code. What i run into is making the element an attribute then it breaks and does not...
0
714
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 : <data> <orders> <order> <order_id>0</order_id> <issue_id>4460</issue_id> <action>add</action>
0
5442
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 an error reflecting the Project type. Is there a way to get any more information about this error? I'm not sure whether it's occuring in the Project class or in one of the contained classes. And I can't tell what's causing the exception. Thanks...
0
1336
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 'System.InvalidOperationException' occurred in system.xml.dll Additional information: There was an error reflecting public class Program {
5
2368
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 here. But what? What do I want?
5
2832
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 like it to return an XML serialized version of an object.
0
348
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, read a work around, but don't know if its the best approach. Here is a link to the error... at least a description. http://support.microsoft.com/default.aspx?scid=kb;en-us;814187 i'm confused though. I looked at Icollection, and there is no...
3
15107
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
422
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 when using the Xml Serializer to serialize a class that has changed the type of a property defined on its base class by using the 'new' keyword. Anyone seen this before? I've tried using the XmlElement attribute as
4
11416
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 look at innerException it says: "Cannot serialize member 'System.ComponentModel.Component.Site' of type 'System.ComponentModel.ISite'. OK it is problem to serialize all data so I'll implement my Serialization. I implemented ISerializable...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9043
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.