473,498 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
1 5385
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2063
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
3
18645
by: J | last post by:
Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number...
2
3498
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
2442
by: bordsby | last post by:
Situation: I am using an OleDbDataAdapter to fill a DataSet's DataTable with data from an Access database. The DataSet's DataTable is bound to a DataGrid. After the OleDbDataAdapter.Fill method...
1
7820
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
11
21836
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on...
0
924
by: SWIL | last post by:
Hi, I made my own datacolumn Class which inherits from Data.DataColumn. To this class I have added 2 properties. To add datacolumn created through my new class I have to call.. ...
3
6184
by: DaveP | last post by:
im Trying to set a Datacolumn type for a new table boolean is not working, What is the correct waty //column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolean"); column.DataType...
0
4511
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two...
0
7125
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,...
0
7002
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...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5462
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,...
0
4588
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...
0
3093
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...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
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 ...

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.