473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

XmlSerializer produces different results in debug and release buil

A few weeks ago, I upgraded an XML server of ours to .NET 2.0. All went
fine. Then last week, I decided to remove all obsolete calls from the app
and sign each project in the solution in the .NET 2 way so that the app
compiled with no warnings. This built fine but we noticed that server was
deserializing one
of our XML messages incorrectly. I confirmed via source control
that neither the schemas themselves nor the classes representing the
messages had been altered but the problem continued.

After some investigation, I found I could I could actively switch this bug
on and off in debug mode by switching between the .NET 1.1 and .NET 2.0 ways
of signing the assembly which contains the serialization code. By this I mean.

..NET 1.1 = Opening assemblyinfo.cs and identifying a key with [assembly:
AssemblyKeyFile(@"somekey)]

..NET 2.0 - Removing this line of code from assemblyinfo.cs and setting
the key to sign the project with in the project proerties dialog.

If I use the .NET 1.1 method, the XML is serialized correctly in debug
build but not in release build. If I use the .NET 2.0 method, the XMl is
serialized wrongly in both builds. I have now reverted all code back to the
original .NET 2.0 build but the problem still persists - debug build is fine
but release build continues to deserialize incorrectly, so I'm completely
lost now. I have pasted below highlights of the xml message as it should
appear, the xml message as it currently appears, the schema I'm working with
and the class which represents the elements being serialized.

Any ideas?

Dan Maharry
MSDN ID: 210068425

---

Correct XML.

<?xml version="1.0" encoding="utf-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<greeting>

....

</greeting>
</epp>

---

Incorrect XML

<?xml version="1.0" encoding="utf-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello d2p1:type="greetingType"
xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance">

....

</hello>
</epp>

---

Schema (relevant pieces)

<?xml version="1.0" encoding="UTF-8" ?>
<schema targetNamespace="urn:ietf:params:xml:ns:epp-1.0"
xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
xmlns:eppcom="urn:ietf:params:xml:ns:eppcom-1.0"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<!--
Import common element types.
-->
<import namespace="urn:ietf:params:xml:ns:eppcom-1.0"
schemaLocation="eppcom-1.0.xsd" />
<annotation>
<documentation>
Extensible Provisioning Protocol v1.0 schema.
</documentation>
</annotation>

<element name="epp" type="epp:eppType" />

<complexType name="eppType">
<choice>
<element name="greeting" type="epp:greetingType" />
<element name="hello" />
<element name="command" type="epp:commandType" />
<element name="response" type="epp:responseType" />
<element name="extension" type="epp:extAnyType" />
</choice>
</complexType>

<complexType name="greetingType">
<sequence>
<element name="svID" type="epp:sIDType" />
<element name="svDate" type="dateTime" />
<element name="svcMenu" type="epp:svcMenuType" />
<element name="dcp" type="epp:dcpType" />
</sequence>
</complexType>

---

C# class generated by xsd.exe

/// <remarks/>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="urn:ietf:params:xml:ns:epp-1.0", TypeName="eppType")]
[System.Xml.Serialization.XmlRootAttribute("epp",
Namespace="urn:ietf:params:xml:ns:epp-1.0", IsNullable=false)]
public class EppType {

private object item;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("hell o",
typeof(object))]
[System.Xml.Serialization.XmlElementAttribute("resp onse",
typeof(ResponseType))]
[System.Xml.Serialization.XmlElementAttribute("gree ting",
typeof(GreetingType))]
[System.Xml.Serialization.XmlElementAttribute("exte nsion",
typeof(ExtAnyType))]
[System.Xml.Serialization.XmlElementAttribute("comm and",
typeof(EppCommandType))]
public object Item {
get {
return this.item;
}
set {
this.item = value;
}
}
}
Apr 26 '06 #1
1 2139
For reference, I've also compiled a small code sample written directly in
..NET 2.0 that demonstrates the same issue although in this case, the
serialization error seems to occur in both debug and release builds. Please
email me if you would like to take a look at the code.
Apr 26 '06 #2

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

Similar topics

3
by: Integer Software | last post by:
Hi. I have a really simple set of classes that writes 2 pathnames to a xml file. I can write the default ok. Then if I change 1 pathname to a shorter one, then rewrite the xml file, the remains...
4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
16
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
2
by: Paul | last post by:
We currently persist our objects to xml/soap files using a SoapFormatter. We control the serialization and de-serialization by implementing the ISerializable and its two interface methods, namely,...
0
by: Shawn Hogan | last post by:
I'm getting two different results when I call System.Reflection.Assembly.GetCallingAssembly when compiling in Release and debug modes. When i compile my application using the "Debug" configuration...
5
by: Lee Gillie | last post by:
A surprising, and unexplained behavior was seen from a RELEASE build of a VB application (essentially a console app). It processes thousands of pages of text, and occasionally drops the first...
6
by: bantamweight | last post by:
Hi, I create a project with vs2005 (both c++ and c# are used, sames the problem is about c++) and it working well in Debug version but the result is wrong in Release version. I checked again and...
8
by: Bruce | last post by:
I am using VB in Vs2005. Am I missing something or does VB not have the concept of "builds" (release/debug) like in VC? I wrote an assembly and I would like to have a debug version of the DLL...
2
by: christopher.watford | last post by:
I'm loading a plugin assembly using Activator.CreateInstanceFrom, and inside this assembly is a settings class which gets serialized to XML. The general code flow is as follows: ObjectHandle...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...

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.