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="gree tingType"
xmlns:d2p1="htt p://www.w3.org/2001/XMLSchema-instance">
....
</hello>
</epp>
---
Schema (relevant pieces)
<?xml version="1.0" encoding="UTF-8" ?>
<schema targetNamespace ="urn:ietf:para ms:xml:ns:epp-1.0"
xmlns:epp="urn: ietf:params:xml :ns:epp-1.0"
xmlns:eppcom="u rn:ietf:params: xml:ns:eppcom-1.0"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" >
<!--
Import common element types.
-->
<import namespace="urn: ietf:params:xml :ns:eppcom-1.0"
schemaLocation= "eppcom-1.0.xsd" />
<annotation>
<documentatio n>
Extensible Provisioning Protocol v1.0 schema.
</documentation>
</annotation>
<element name="epp" type="epp:eppTy pe" />
<complexType name="eppType">
<choice>
<element name="greeting" type="epp:greet ingType" />
<element name="hello" />
<element name="command" type="epp:comma ndType" />
<element name="response" type="epp:respo nseType" />
<element name="extension " type="epp:extAn yType" />
</choice>
</complexType>
<complexType name="greetingT ype">
<sequence>
<element name="svID" type="epp:sIDTy pe" />
<element name="svDate" type="dateTime" />
<element name="svcMenu" type="epp:svcMe nuType" />
<element name="dcp" type="epp:dcpTy pe" />
</sequence>
</complexType>
---
C# class generated by xsd.exe
/// <remarks/>
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="urn:iet f:params:xml:ns :epp-1.0", TypeName="eppTy pe")]
[System.Xml.Seri alization.XmlRo otAttribute("ep p",
Namespace="urn: ietf:params:xml :ns:epp-1.0", IsNullable=fals e)]
public class EppType {
private object item;
/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "hello",
typeof(object))]
[System.Xml.Seri alization.XmlEl ementAttribute( "response",
typeof(Response Type))]
[System.Xml.Seri alization.XmlEl ementAttribute( "greeting",
typeof(Greeting Type))]
[System.Xml.Seri alization.XmlEl ementAttribute( "extension" ,
typeof(ExtAnyTy pe))]
[System.Xml.Seri alization.XmlEl ementAttribute( "command",
typeof(EppComma ndType))]
public object Item {
get {
return this.item;
}
set {
this.item = value;
}
}
} 1 2152
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 of the old pathname,
and closing tags are left on the end resulting in an invalid XML file.
XmlSerializer.Deserialize gives a System.InvalidOperationException with
additional information: Error in the XML document.
My default file for example...
|
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 should have worked fine since the class in question was already being serialized and deserialized as part of a Web service interface. What I found was that by deserializing from an XmlNodeReader instead of an XmlTextReader, XML Serialization doesn't work...
|
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>
.......
.......
</ArrayOfClassname>
|
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, GetObjectData and a
constructor that takes two arguments (a SerializationInfo object and a
StreamingContext object).
It appears with the release of .net 2.0 that support for the SoapFormatter
is 'frozen' and that the direction we should take is...
|
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
my call to GetCallingAssembly returns the assembly name of the project that
contains my form and class(as expected). When i compile using the "Release"
configuration GetCallingAssembly unexpectedly returns System.Windows.Forms.
Below is some...
| |
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 character of the first
line of the page. I really felt this was likely my own bug. In a DEBUG
build now I captured data from the page and wrote the result for each
page to the debug window. The result was consistent with the release
build, and...
|
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 again and no
difference of logic is found between two versions. I'm confused and
don't known how to correct it. Is there anyone encountered similar
deed? Any tips is wellcome.
Regards.
|
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 and a release
version of the DLL. I would like to create some sample code that
demonstrates my assembly in VB and would like to have two builds, one
using my debug version and the other using the release version of the
assembly.
How can I do...
|
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 pluginHandle = Activator.CreateInstanceFrom(assemblyName,
type);
object plugin = pluginHandle.Unwrap();
....
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
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
| |