473,657 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlIgnoreAttrib ute() ignoring other attributes then intended

Perhaps I'm using this wrong. When I use
[System.Xml.Seri alization.XmlIg noreAttribute()] above an attribute I don't
want serialized it ignores the attribute. It also ignores some other
attributes. Have I done something wrong?

Here's the serialization code

public Form1()

{

testClass test = new testClass();

InitializeCompo nent();

try

{

XmlSerializer x = new XmlSerializer(t ypeof(testClass ));

TextWriter writer = new StreamWriter("\ \" + "test.xml") ;

x.Serialize(wri ter, test);

}

catch (Exception e)

{

MessageBox.Show (e.ToString());

}

}

Here's the class being serialized. Sorry that it's so long but I couldn't
reproduce this with a shorter class I made

namespace XML_test1{

using System.Xml.Seri alization;

using System;

using System.Drawing;

using System.Collecti ons;

using System.Componen tModel;

using System.Windows. Forms;

using System.Data;

using System.Xml;

using System.Xml.Sche ma;

using System.IO;
[System.CodeDom. Compiler.Genera tedCodeAttribut e("xsd", "2.0.50727. 42")]

// [System.Serializ ableAttribute()]

[System.Diagnost ics.DebuggerSte pThroughAttribu te()]

[System.Componen tModel.Designer CategoryAttribu te("code")]

[System.Xml.Seri alization.XmlTy peAttribute(Ano nymousType=true )]

public partial class testClass {

private string eventTypeField;

private string pSCommonField;

private string loadArrivalNumb erField;

private string incomingLDSNumb erField;

private string transportIdenti fierField;

private string sourceField;

private string cutblockIDField ;

private string fieldScaleFlagF ield;

private string fieldScaleDeckI DField;

private string weighSlipNumber Field;

private string originatingScal eSiteNumberFiel d;

private string splitLoadField;

private string beachcombField;
private string checkScaleField ;

private string pSMeasureField;

private string dDNField;

private string dvField;

private bool beachcombFieldS pecified;
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 0)]

public string EventType

{

get

{ return this.eventTypeF ield;}

set

{this.eventType Field = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 1)]

public string PSCommon

{

get

{ return this.pSCommonFi eld;}

set

{ this.pSCommonFi eld = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 2)]

public string LoadArrivalNumb er

{

get

{return this.loadArriva lNumberField; }

set

{this.loadArriv alNumberField = value; }

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 3)]

public string IncomingLDSNumb er

{

get

{ return this.incomingLD SNumberField;}

set

{this.incomingL DSNumberField = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 4)]

public string TransportIdenti fier

{

get

{ return this.transportI dentifierField; }

set

{ this.transportI dentifierField = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 5)]

public string Source

{

get

{ return this.sourceFiel d; }

set

{ this.sourceFiel d = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 6)]

public string CutblockID

{

get

{return this.cutblockID Field;}

set

{this.cutblockI DField = value; }

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 7)]

public string FieldScaleFlag

{

get

{ return this.fieldScale FlagField; }

set

{ this.fieldScale FlagField = value; }

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 8)]

public string FieldScaleDeckI D

{

get

{ return this.fieldScale DeckIDField; }

set

{ this.fieldScale DeckIDField = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 9)]

public string WeighSlipNumber

{

get

{ return this.weighSlipN umberField; }

set

{ this.weighSlipN umberField = value; }

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 10)]

public string OriginatingScal eSiteNumber

{

get

{ return this.originatin gScaleSiteNumbe rField; }

set

{ this.originatin gScaleSiteNumbe rField = value; }

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 11)]

public string SplitLoad

{

get

{ return this.splitLoadF ield;}

set

{ this.splitLoadF ield = value;}

}
[System.Xml.Seri alization.XmlEl ementAttribute( Order = 12)]

public string Beachcomb

{

get

{ return this.beachcombF ield;}

set

{ this.beachcombF ield = value;}

}

[System.Xml.Seri alization.XmlEl ementAttribute( Order = 13)]

public string CheckScale

{

get

{ return this.checkScale Field;}

set

{this.checkScal eField = value;}

}

[System.Xml.Seri alization.XmlEl ementAttribute( Order = 14)]

public string PSMeasure

{

get

{ return this.pSMeasureF ield; }

set

{ this.pSMeasureF ield = value; }

}
[System.Xml.Seri alization.XmlAt tributeAttribut e()]

public string DDN

{

get

{ return this.dDNField; }

set

{ this.dDNField = value; }

}

[System.Xml.Seri alization.XmlAt tributeAttribut e(DataType = "integer")]

public string DV

{

get

{ return this.dvField; }

set

{ this.dvField = value; }

}
// Somehow this ignore statement is removing other attributes not just this
attribute
// System.Xml.Seri alization.XmlAt tributeAttribut e()

[System.Xml.Seri alization.XmlIg noreAttribute()]

public bool BeachcombSpecif ied

{

get

{ return this.beachcombF ieldSpecified; }

set

{ this.beachcombF ieldSpecified = value; }

}

public testClass()

{

EventType = "1";

PSCommon = "2";

LoadArrivalNumb er = "3";

IncomingLDSNumb er = "4";

TransportIdenti fier = "5";

Source = "6";

CutblockID = "7";

FieldScaleFlag = "8";

FieldScaleDeckI D = "9";

WeighSlipNumber = "10";

OriginatingScal eSiteNumber = "11";

SplitLoad = "12";

Beachcomb = "13";

CheckScale = "14";

PSMeasure = "15";

DDN = "16";

DV = "17";

BeachcombSpecif ied = false; //should be ignored

}
}
}

Here's the results

<?xml version="1.0" encoding="utf-8"?>

<testClass xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">

<EventType>1</EventType>

<PSCommon>2</PSCommon>

<LoadArrivalNum ber>3</LoadArrivalNumb er>

<IncomingLDSNum ber>4</IncomingLDSNumb er>

<TransportIdent ifier>5</TransportIdenti fier>

<Source>6</Source>

<CutblockID>7 </CutblockID>

<FieldScaleFlag >8</FieldScaleFlag>

<FieldScaleDeck ID>9</FieldScaleDeckI D>

<WeighSlipNumbe r>10</WeighSlipNumber >

<OriginatingSca leSiteNumber>11 </OriginatingScal eSiteNumber>

<SplitLoad>12 </SplitLoad>

</testClass>

as you can see the last 5 fields did not make it to the XML.

If you simply comment out the

[System.Xml.Seri alization.XmlIg noreAttribute()]

public bool BeachcombSpecif ied

{

get

{ return this.beachcombF ieldSpecified; }

set

{ this.beachcombF ieldSpecified = value; }

}

and it's entry in the constructor

BeachcombSpecif ied = false; //should be ignored

they do make it

Once again this is done in the compact framework
Apr 11 '06 #1
2 3757
Hi Jamie,

Thanks for providing with us the code to repro this problem. Yes, I can
reproduce this on my machine. I will try to contact the product team on it
to see if we can get a workaround.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Apr 12 '06 #2
Hi Jamie,

This might be a bug in the compact framework. You can try to contact
Microsoft PSS for a workaround. Here is the contact information

http://support.microsoft.com/default...;OfferProPhone

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =============== =============== =
=============== ===========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =============== =============== =
=============== ===========

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2720
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a namespace prefix, what is its namespace, if default namespaces do not apply? Are (either of) prefixed or non-prefixed attributes correct? For example, are the following equivalent: <html:br class="foo"...
2
3510
by: Dean A. Hoover | last post by:
I am attempting to parse an extremely simple xml file that has an embedded DTD using java sax2. Here is the xml file: <?xml version="1.0" ?> <!DOCTYPE foo > <foo> <bar/> </foo>
2
1147
by: Eric Smith | last post by:
I'm writing a DTD for a simulator to save the state of the simulated machine, such as register and memory contents. In this particular application, it is not expected that the generated XML will normally be seen or edited by a person, either as text or in a structured XML editor. It is only intended as an intermediate storage format, so that the same state can be loaded back into the simulator at a later time. My first thought was to...
5
3855
by: WindAndWaves | last post by:
Greetings once more, I was wondering if someone figured out the difference between attributes and properties. I noticed that things like fields have a number of properties, but also attributes. For example, right now, I am looking for the rowsource property for a field in a table. How do I find that?
5
2574
by: Mike | last post by:
Currently, when my application needs to write/read to a database, there is a time lag. In that time lag, a user can click the same button multiple times causing my app problems. I want to turn the mouse pointer arrow into an hourglass and ignore mouse clicks until my app finishes working. Most commercial apps I've looked at do this. Is there an easy way to do this (ie. any built-in controls in VS.NET or classes in MSDN)? Any...
0
1127
by: Saradhi | last post by:
Hi All , I am using the Code model for Generating the VB code on the Fly. I am able to generate a new class with the Variables, Fields and Methods I want. Now What I want is the facility to modify a Member's Details inside my already generated Class. For Ex: Protected m_OilProd As TimeSeriesDoublePublic Overridable Property OilProd() As TimeSeriesDoubleGet Return m_OilProdEnd Get Set(ByVal Value As TimeSeriesDouble) ...
6
1456
by: Jan Nielsen | last post by:
Hi all I have a typed dataset (vb.net) that the wizard created. I have a photo in the dataset that I do not want to get xml serialized. I use the function dataset.WriteXml() to serialize. It seems that I should use the XmlIgnoreAttribute. But where do I use this??? The dataset.vb is a very complex class
5
15971
by: s.luongo | last post by:
Hello everybody, Trying to get all attributes from a class (class1), I got them through properties, is it a simple way to get all class atributes not using their properties?? public void GetAllClassAttributes() {
44
2921
by: Steven D'Aprano | last post by:
I have a class which is not intended to be instantiated. Instead of using the class to creating an instance and then operate on it, I use the class directly, with classmethods. Essentially, the class is used as a function that keeps state from one call to the next. The problem is that I don't know what to call such a thing! "Abstract class" isn't right, because that implies that you should subclass the class and then instantiate the...
0
8407
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
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 we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.