467,879 Members | 1,210 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,879 developers. It's quick & easy.

Serializing DataColumn

I'm having trouble Serializing a System.Data.DataColumn
object. When I try to serialize it, I get the following:

System.NotSupportedException: Cannot serialize member
System.ComponentModel.MarshalByValueComponent.Site of
type System.ComponentModel.ISite because it is an
interface.

I tried a number of workarounds without sucess:

1. I tried subclassing DataColumn with my own class,
overriding the Site property and setting the
[XMLIgnoreAttribute] on the Site property.

2. I tried creating an XML serialization override:

XmlAttributeOverrides xOver = new XmlAttributeOverrides();
XmlAttributes attrs = new XmlAttributes();

attrs.XmlIgnore = true;
xOver.Add(typeof(DMSDataColumn), "Site", attrs);

XmlSerializer mySerializer = new XmlSerializer(typeof
(DataColumn), xOver);

Neither of the above worked--both issued threw the same
exception about not being able to serialize Site. It
seems as though the XML Serializer is hellbent on trying
to serialize the Site property no matter what I do to
tell it to ignore Site.

I know there is the option of serializing the DataColumn
indirectly by serializing a DataSet. This option will
not work for me as I do not want to serialize all the
columns and rows of the DataTable. I just want to
serialize one DataColumn in the DataTable.

Please help!

Thanks!
Nov 15 '05 #1
  • viewed: 5033
Share:
1 Reply
You could copy the DataColumn to an empty DataSet, and serialize the
DataSet. Afterwards you could get the column out of the DataSet. I know that
this is not a nice solution, but it will probably work...

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Chris" <an*******@discussions.microsoft.com> schreef in bericht
news:01****************************@phx.gbl...
I'm having trouble Serializing a System.Data.DataColumn
object. When I try to serialize it, I get the following:

System.NotSupportedException: Cannot serialize member
System.ComponentModel.MarshalByValueComponent.Site of
type System.ComponentModel.ISite because it is an
interface.

I tried a number of workarounds without sucess:

1. I tried subclassing DataColumn with my own class,
overriding the Site property and setting the
[XMLIgnoreAttribute] on the Site property.

2. I tried creating an XML serialization override:

XmlAttributeOverrides xOver = new XmlAttributeOverrides();
XmlAttributes attrs = new XmlAttributes();

attrs.XmlIgnore = true;
xOver.Add(typeof(DMSDataColumn), "Site", attrs);

XmlSerializer mySerializer = new XmlSerializer(typeof
(DataColumn), xOver);

Neither of the above worked--both issued threw the same
exception about not being able to serialize Site. It
seems as though the XML Serializer is hellbent on trying
to serialize the Site property no matter what I do to
tell it to ignore Site.

I know there is the option of serializing the DataColumn
indirectly by serializing a DataSet. This option will
not work for me as I do not want to serialize all the
columns and rows of the DataTable. I just want to
serialize one DataColumn in the DataTable.

Please help!

Thanks!

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ivo Bronsveld | last post: by
3 posts views Thread by J | last post: by
2 posts views Thread by Tobias Zimmergren | last post: by
3 posts views Thread by DaveP | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.