Exception while creating XmlSerializer with XmlAttributeOverrides.

I am using XmlSerializer with XmlAttributeOverrides. The
XmlAttributeOverrides are used for properties which hold element/s
derived from "AbstractMessage" type.

System.Xml.Serialization.XmlRootAttribute(Namespace = "http://
www.TestNameSpace.org/Test-4-4", IsNullable = false)]
    class Root
    {
        [System.Xml.Serialization.XmlElementAttribute(Type =
typeof(Abstract_message), ElementName = "Message", IsNullable =
false)]
        public virtual Abstract_message Message
        {
            get { return this._messageField; }
            set{ this._messageField = value; }
        }

        [System.Xml.Serialization.XmlElementAttribute(Type =
typeof(BatchMesssage), ElementName = "Batch", IsNullable = false)]
        public virtual Batch_tCollection Batch
        {
            get {  return this._batchField; }
            set{ this._batchField = value; }
        }
    }

[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://
www.TestNameSpace.org/Test-4-4")]
    public class BatchMesssage
    {
        ///
        [System.Xml.Serialization.XmlElementAttribute("Hdr", Order =
0, IsNullable = false)]
        public BatchHeader_t Hdr
        {
            get{ return this._hdrField; }
            set { this._hdrField = value; }
        }


        [System.Xml.Serialization.XmlElementAttribute("Message", Order
= 1, IsNullable = false, Type = typeof(Abstract_message_t))]
        public Abstract_message_tCollection Messages
        {
            get {  return this._messageField; }
            set { this._messageField = value; }
        }
    }

where type "Batch_tCollection" is a collection of "BatchMessage" type
items.


For type "Root" "BatchMessage" I provide XmlAttributeOverrides for
property "Message" & "Messages" respt. :

System.Xml.Serialization.XmlAttributeOverrides attribOverrides = new
System.Xml.Serialization.XmlAttributeOverrides();
System.Xml.Serialization.XmlAttributes msgAttribs  = new
System.Xml.Serialization.XmlAttributes();
msgAttribs.XmlElements.Add(new
System.Xml.Serialization.XmlElementAttribute("TestMessageRoot",
typeof(TestMessage)));
attribOverrides.Add(typeof(Root), "Message", msgAttribs);
attribOverrides.Add(typeof(BatchMesssage), "Message", msgAttribs);

 where type "TestMessage" is derived from "AbstractMessage" type.


When I try to instantiate the XmlSerializer with the above
XmlAttributeOverrides as parameter to the constructor it throws the
following exception:

Exception:
System.InvalidOperationException was caught
  Message="There was an error reflecting type 'Root'."
  Source="System.Xml"
  StackTrace:
       at
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType,
XmlAttributes a, Boolean repeats, Boolean openModel)
       at
System.Xml.Serialization.XmlReflectionImporter.ImportElement(TypeModel
model, XmlRootAttribute root, String defaultNamespace)
       at
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type
type, XmlRootAttribute root, String defaultNamespace)
       at System.Xml.Serialization.XmlSerializer..ctor(Type type,
XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute
root, String defaultNamespace, String location, Evidence evidence)
       at System.Xml.Serialization.XmlSerializer..ctor(Type type,
XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute
root, String defaultNamespace)

Inner Exception: There was an error reflecting property 'Batch'.
Inner Exception: There was an error reflecting type 'BatchMessage'.
Inner Exception: Inconsistent sequencing: if used on one of the
class's members, the 'Order' property is required on all particle-like
members, please explicitly set 'Order' using XmlElement, XmlAnyElement
or XmlArray custom attribute on class member 'Messages'.


In the above case if I remove the sequencing property ("Order") from
the XmlElementAttribute applied on BatchMessage member properties, the
thing seems to work correctly.

Am I using the XmlAttributeOverride in the right place? Any help on
the above will be appreciated.
Thanks in advance.

0
6/21/2007 3:12:49 PM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies
990 Views

Similar Articles

[PageSpeed] 19

Reply:

Similar Artilces:

ADO Exceptions
������: "Tony Tanm" <tony21st@sina.com.cn> ����: One question about ADO ����: 2003��8��22�� 14:48 I use ADO in my application to access database,when I give the parameter ConnectionString of connection's method Open a wrong value(say,data source that doesn't exist),my program will arouse exception, through step debugging, I found that the following code [in msado20.tli file] if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); lead to the exception. I'm puzzled about it. Somebody help me please. Thanks in advance. Tony, you have several opti...

GP10 install.dll error when creating new company
Hi, When I try to create a new company in GP10 I am getting an install.dll error. Any ideas of how to resolve this. Neil ...

Creating Bubble Charts
How do you create a bubble chart that displays the legend as a description of the 3rd variable (the bubble size)? For example, how would you create the following bubble chart where the x-axis is column B, y-axis is column C, bubble size is column D and legend is column A? A1: B1:Gross Rev C1:Net Income D1:# of Plants A2:East B2:830,000 C2:35,000 D2:26 A3:West B3:620,000 C3:54,000 D3:13 A4:North B4:150,000 C4:80,000 D4:40 A5:South B5:41,000 C5:15,000 D5:35 Any insight will be helpful! Hi Tina I would create a bubble chart and use one of the following tools for labelling the...

CDHtmlDialog Exception
Any idea why I'm getting this exception the second time that I show a modal dialog with a CDHtmlDialog control on it? Thanks. 0:015> !analyze -v ******************************************************************************* * * * Exception Analysis * * * ******************************************************************************* FAULTING_IP: RPCRT4!CStdProxyBuffer_QueryInterface+a 76b5e134 832300 and dword ptr [ebx],0 EXCEPTION_RECORD: ffffffff -- (.exr ffffffffffffffff) ExceptionAddress: 76b5e134 (RPCRT4!CStdProxyBuffer_Qu...

Visio Prof 2002: Creating phone trees
I've done flowcharts & UML in Visio (very easy!, but trying to create a phone tree is proving difficult. 1. Should I do this as a Block Diagram? a. If so, what type of connections? I can place squares and use the "Dynamic Connector", but this is very manual. I've tried using the "Multi-tree square", but am only able to lock onto one box per branch. 2. Is there a better diagram type then Block? And if so, what is the best connection type between the boxes? To clarify, I am trying to create a phone tree for several 1-800 numbers that have many many option...

Creating New Recipients
Hello, I need to find out how to automate the process of creating new recipients with the company address and other information already there. Can this be done? I am running Exchange 5.5 SP4 on a Windows 2000 SP4 platform. 2GB or RAM, Dual 2.4 GHZ Zeon (Hyperthreaded) processors. The reason I need to automate is because I have two other people that create mailboxes and refuse to take the time and fill out the proper information. Your assistance is very appreciated Sincerely Matt Newman NT\2K Syatems Administrator Is there no one out there that can help me with this, Please? Matt Newma...

problems in creating file dialog in tab control
Hi,I am creating a tab control and want to pop up a file dialog when clicking one tab page. but now, the file dialog was shown up at the same time with tab control, not after selecting one page. Could some guys help me? Thanks David GetClientRect(hwndParent,&rcClient); InitCommonControls(); hwndTabCtrl=CreateWindow(WC_TABCONTROL,"", WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndParent,NULL,g_hinst,NULL); if(hwndTabCtrl==NULL) AfxMessageBox("can't create tab control window"); m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE; m_tcitem.iIma...

Creating new option button groups
I have a worksheet with a pair of option buttons (Male/Female), both referencing the same cell. This works fine. I now wish to add another pair of buttons (Yes/No). However when I add a new button (by selecting the radio button in the Forms toolbar and then clicking in the sheet) the new button has the same cell reference as the first pair. When I give it a new cell reference to create a separate Y/N group, the cell reference in the first pair of buttons (M/F) also changes so that all three buttons always have the same cell reference. How do I deal with this? Any suggestions wo...

Confused! Can I create an XML document from an XSD file?
I am confused. I was given a fairly complex xsd schema for use in a project. When I added this to a website in VS 2005, it shows up in intellesense and I can instantiate, manipulate it etc. with the following code in the BLL layer: public LXML CreateLXML(ref Tsrsubi1.Xormsga2 etx) { LXML lxml = new LXML(); DateTime dt = DateTime.Now; string lenderid = _dal.GetLenderId(etx.orderHeader.custId.ToString()); lxml.Order[0]._ProductType = "TSR"; lxml.Order[0]._OrderRef = etx.orderHeader.orderNo.ToString(); lxml.Status[0].MessageCode = "1050"; lxml.Status[0].MessageTextCode = &...

Outlook profile not created on login
Hi, I have a .mst file that I have already setup in a batch file that I use to install Office 2000 on Terminal Servers/Metaframe Servers. I've used this many times in the past. I just built 2 new servers and one of them does not populate the Outlook settings for new users. By settings I mean the exchange server name, name, personal folder location, etc. The settings for Word, Excel, Powerpoint are there though. I then uninstalled Office, rebooted, reinstalled it and get the same thing. I looked in the registry and the NewProf key is there with all the correct settings in it. ...

Creating rules........
Hi, In Work flow manager I created 2 rules(check conditions and wait for timer) and applied those rules to the contact list� but after creating the rule I manually selected few contacts from the contact list and from the action menu I applied my own rules� My question is 1) When ever I create a contact, leads� will my rule be automatically incorporated to the contact (instead of going thru actions and specifying the rule)? 2) What ever we want, we want to go thru action and do it manually... is there any feature in CRM where all the specified actions does itself. I want to know weather ...

unable to create a link in email
hi, how can i create a link in my outlook email to link to C:\my documents\How to blade.doc thanks I really don't know, but even if you could, the recipient couldn't see it. It's on your computer. The only way is to attach the file to your message. I would also suggest that your create a PDF so that recipients that don't have Word can read it. Win2PDF at http://www.win2pdf.com or PrimoPDF at http://www.primopdf.com "Lynn" <moley_cruz@yahoo.com.au> wrote in message news:1106799740.913670.178870@z14g2000cwz.googlegroups.com... > hi, > how can i creat...

How can i create a link to a PDF document within my Publisher Email?!
Hello, I have created a newsletter to send to my clients using Publisher 2007. I need to insert a price list as a link within the body of the newsletter (NOT as an email attachment) , for example: ''Click Here to view our price list'' I need to create a link from 'Click Here' to open the PDF file which will display the price list. Is this possible? Anticipating your reply! Thank you in advance, Bonnie If you are willing to store the PDF file on a server, yes. Storing the PDF file on a server will require you to give it a website address but y...

Exception from HRESULT: 0x80040E2F
We have a custom task list that seems to get this error when trying to update a list item that only has a user assigned to that task. When there is no user assigned you can update the list item and attach the file. We have ran a sync against AD and nothing has worked so far. ------=_NextPart_0001_8D145796 Content-Type: text/plain Content-Transfer-Encoding: 7bit Restart the below services and then try: � Windows SharePoint Services Timer � Windows SharePoint Services Administration � Windows SharePoint Services Tracing ------=_NextPart_0001_8D145796 Content-Type: text/x-r...

Creating a sub domain
Dear All I have created one Primary domain and a Secondary domain server in my local infrastructure already.My primary domain name is EXAMPLE.COM.It contain only 175 node.Now we going to start a branch office for our company.So i need to create a sub domain for my primary domain server like BRANCH.EXAMPLE.COM.It contain 100 node. Now i wand to know how to create a sub domain.What is the best way to create it.What I mean that is it i install my sub domain server on my main office and then ship it into the branch office.Otherwise i will create sub domain in my branch office through ...

Updates were not accepted (exception 4005). Soap exception.
Hi all, when the report is submitted from Outlook 2003 to Project Server 2007 the folowing error message is displayed (see the subj). However, the data are being sent and can be seen in PWA. At the same time, the user gets an email message from Project Server: "Project server returned error code -1". What's wrong with the Server or client? where to look for? Please advise. Elena ...

Create List or Dictionary
Hello, I need to create a List or a Dictionary with only to items: Id = 1, Key = "Subscribe" Id = 2, Key = "Unsubscribe" Is it possible to create such a list or dictionary with only one code line? Thank You, Miguel Dictionary<string, int> toto = new Dictionary<int, string> { { "Subscribe" , 1}, { "Unsubscribe", 2 } }; Vanderghast, Access MVP "shapper" <mdmoura@gmail.com> wrote in message news:a31b4a74-f280-490b-a608-a5a2dfc357cb@r34g2000yqj.googlegroups.com... > Hello, > > I ...

Automaticaly create montly calendars for 30 employees
Each employee has a different schedule. For each employee I have created a grid that summarizes their schedule, for example, employee A's grid reads: 1st Week Mon Tue Wed Thur Fri of the month work work off meeting work 2nd Week Mon Tue Wed Thur Fri of the month work off off work work 3rd Week etc. etc. etc. etc. of the month To create my monthly work calendars, I look at the employees grids and manualy enter the inform...

Creating links
How do I make a field on the profile page in an Education template that is a link that would bring you to a detail page where lists of courses a student takes can be gathered. -- Enjoy every day! I'm having trouble visualizing your underlying data structure ... you did post in a newsgroup dedicated to supporting the design of tables in Access databases ... What do you mean by "the profile page"? Which "Education template"? What "detail page"? Courses available to students or courses already taken by students? More info, please! ...

Creating a Shortcut for Macro >> Continue
Is it possible to create a hotkey or another macro for continuing a macro? I tried this macro: CommandExec form BuiLtin command cmdMacroPause but doesn't work. Thanks Zoltan ...

Prompt to Ask If User Wants to Create a Duplicate Record
For example, let's say there's already a record for Mary Shelly, and I have a new Mary Shelly that I'm trying to add to my database. Can I make it so that Access will prompt me and say "There is already a record matching this description. Do you wish to continue?" Hi Dove, I'm assuming first and last name are in the same field. Create a button or Label and add this code to the On Click event but make the following changes to the code: NAMEFIELD= The name of the field where the name is kept on the form TABLEWITHUSERNAMES = The name of the table where the username i...

Programmatically creating a pass-through query
Hi, Is there a way to programmatically create pass-through query in Access 2003? Sub test () Dim db As Database Dim strSQL As String Dim qdfs As QueryDefs Dim qdf As QueryDef strSQL ="Some pass-through SQL statement here" Set db = CurrentDb Set qdfs = db.QueryDefs Set qdf = db.CreateQueryDef("qry_PassThru", strSQL) qdf.SQL = strSQL End Sub But the code about will not create a pass-through query, Access thinks it is a regular Access query. Is there a way to specify ...

Creating Users
Somebody created a few users on a machine without ESM installed. I need to add an Exchange mailbox for these folks. We recently upgraded to 2003 (both domain and exchange), and I think I'm missing something. I right click n the user, select Exchange task. The only option available is to remove exchange attributes. Sure enough, clicking on the user shows a few of the Exchange tabs, but not the Email Address tab. What's the process for adding email addresses / mailboxes to existing users in this type of scenario? I do not want to delete/recreate the user. Must I remove attr...

Creating line charts
Hi, I need to create a chart which has months of the year on one axis with 6 names on the other and have to pick up a figure for G8:R8 (Tom), G16:R16 (Sarah), G29:R29 (Emma), G34:R34 (Lindsay, G41:R41 (Divya) and G46:R46 (Tayub). It's been ages since I've had to do this, so any help would be gratefully accepted. I don't understand your data. Don't you mean, months across the horizontal axis, some value against the vertical axis, and one line per person's name in the chart? If so, presumably the months are in another range, like G1:R1. Start the chart wizard, and o...

Account created itself on Exchange Server
Hello Friends, According to Event viewer, an account name as "sbsmonacct" is created itself and join Enterprise admin Group (member of this group). This event is logged into event viewer with this user S-1-5-21-XXXXXXXXXX-XXXXXXXXX......... I want to know, is this account is created by any Exchange Process or any services Or someone is playing with our server intensionally(means entering from back door). do anyone have any idea, what is going on with exchange server. Regards G. Gureey <Gureey@discussions.microsoft.com> wrote: >According to Event viewer, an account ...