PC Review


Reply
Thread Tools Rate Thread

Can't seem to supply an XmlIgnore override on a Control's Site me

 
 
=?Utf-8?B?bmlja2R1?=
Guest
Posts: n/a
 
      18th Nov 2005
I'm trying to serialize, via the XmlSerializer, an object which is derived
from System.Windows.Forms.Control. It throws an exception complaining about
not being able to serialize the Site property. I expected problems and my
plan was to work through them one at a time supplying an XmlIgnore attribute
for each of the properties it had problems with. However, for some reason
this doesn't seem to work. The code is below. Does anyone know why it's
still throwing the exception complaining about the Site property after
specifying the XmlIgnore attribute for that property?

using System;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.IO;
using System.Drawing;

public class MyControl : Control
{
public MyControl()
{
}
}

public class Application
{
public static void Main()
{
MyControl control = new MyControl();
XmlSerializer serializer;
XmlAttributes attributes;
XmlAttributeOverrides overrides;

overrides = new XmlAttributeOverrides();
attributes = new XmlAttributes();
attributes.XmlIgnore = true;
overrides.Add(typeof(MyControl), "Site", attributes);
control.Font = new Font("Arial", 12);
serializer = new XmlSerializer(typeof(MyControl), overrides);
serializer.Serialize(Console.OpenStandardOutput(), control);
}
}
--
Thanks,
Nick
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlIgnore an inherited attribute bg_ie@yahoo.com Microsoft C# .NET 2 18th Oct 2007 04:03 PM
Xml Serialization - Defaulting to XmlIgnore? Undergrid Microsoft C# .NET 0 5th Mar 2007 06:08 PM
XMLIgnore Atribute =?Utf-8?B?Um9iZXJ0IFcu?= Microsoft C# .NET 2 15th Sep 2005 07:57 PM
Can't override ProcessCmdKey in control Teis Draiby Microsoft Dot NET Framework Forms 0 20th Dec 2004 04:14 PM
[xmlIgnore] Romain TAILLANDIER Microsoft Dot NET Framework 1 1st Dec 2003 06:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 AM.