By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

Serializing DataColumn

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.