I've seen this come up before, but in my case, things are a little more
complex, and I'm having a tough time figuring out how to set an element name
that works. I have a configuration file that is my serialized object (I'm
using a customer deserializer to add some more XAML-like capabilities):
<AppConfigObjec t>
<RuntimeType:Ke rnel xmlns:RuntimeTy pe="MyNamespace .DefaultKernel, Kernel"/>
</AppConfigObject >
public class AppConfigObject {
[XmlElement]
public Kernel {...}
}
Problem I have is deserializing the child node <Kernel> because it always
throws an error about "<Kernel xmlns='MyNamesp ace.DefaultKern el, Kernel'>
was not expected.". I'm hoping that it's just something I'm missing (I've
tried several combinations of element names and defaultNamespac es) and it's
not that what I am trying is not possible. 10 6936
Your XML document states that the <Kernel> element belongs to the
"MyNamespace.De faultKernel, Kernel" namespace, but your serialization
attribute does not declare the namespace.
Try:
public class AppConfigObject {
[XmlElement(Name space="MyNamesp ace.DefaultKern el, Kernel")]
public Kernel {...}
}
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Keith Patrick" <ri************ *******@nospamh otmail.com> wrote in message
news:uK******** ********@TK2MSF TNGP11.phx.gbl. .. I've seen this come up before, but in my case, things are a little more complex, and I'm having a tough time figuring out how to set an element name that works. I have a configuration file that is my serialized object (I'm using a customer deserializer to add some more XAML-like capabilities): <AppConfigObjec t> <RuntimeType:Ke rnel xmlns:RuntimeTy pe="MyNamespace .DefaultKernel, Kernel"/> </AppConfigObject >
public class AppConfigObject { [XmlElement] public Kernel {...} }
Problem I have is deserializing the child node <Kernel> because it always throws an error about "<Kernel xmlns='MyNamesp ace.DefaultKern el, Kernel'> was not expected.". I'm hoping that it's just something I'm missing (I've tried several combinations of element names and defaultNamespac es) and it's not that what I am trying is not possible.
Your XML document states that the <Kernel> element belongs to the
"MyNamespace.De faultKernel, Kernel" namespace, but your serialization
attribute does not declare the namespace.
Try:
public class AppConfigObject {
[XmlElement(Name space="MyNamesp ace.DefaultKern el, Kernel")]
public Kernel {...}
}
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Keith Patrick" <ri************ *******@nospamh otmail.com> wrote in message
news:uK******** ********@TK2MSF TNGP11.phx.gbl. .. I've seen this come up before, but in my case, things are a little more complex, and I'm having a tough time figuring out how to set an element name that works. I have a configuration file that is my serialized object (I'm using a customer deserializer to add some more XAML-like capabilities): <AppConfigObjec t> <RuntimeType:Ke rnel xmlns:RuntimeTy pe="MyNamespace .DefaultKernel, Kernel"/> </AppConfigObject >
public class AppConfigObject { [XmlElement] public Kernel {...} }
Problem I have is deserializing the child node <Kernel> because it always throws an error about "<Kernel xmlns='MyNamesp ace.DefaultKern el, Kernel'> was not expected.". I'm hoping that it's just something I'm missing (I've tried several combinations of element names and defaultNamespac es) and it's not that what I am trying is not possible.
The thing is, I can't set it like that in the class, because the Kernel
property is of type "BaseKernel ", of which "DefaultKer nel" is a subclass
(this is basically a new serializer that supports concrete implementations
of abstract properties and list items). I tried also setting
defaultNamespac e in my serializer, but the problem there is that I need to
set defautlNamespac e *and* default element name in teh XmlRootAttribut e,but
I can't set both without also having to provide some other params (the last
ctor for that attribute) that I cannot pass in as null, as it throws an
exception in XRA.
The way I think I am going to go is to declare my stuff like this:
<AppConfigObjec t>
<Kernel>
<MyNamespace.De faultKernel Name="..." Attr2="..."/>
</Kernel>
</AppConfigObject >
and just go through every assembly in the appdomain to look for
MyNamespace.Def aultKernel (it's a somewhat slow process, as it's heavy into
reflection and has to iterate through several assemblies, but this stuff is
all part of startup and not regular operation. Another downside is that I
can't have two assemblies in the appdomain with the same namespace + class,
but I can live with that limitation until I replace the config format with
XAML snippets)
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:O9******** ******@TK2MSFTN GP11.phx.gbl... Your XML document states that the <Kernel> element belongs to the "MyNamespace.De faultKernel, Kernel" namespace, but your serialization attribute does not declare the namespace.
Try:
public class AppConfigObject { [XmlElement(Name space="MyNamesp ace.DefaultKern el, Kernel")] public Kernel {...} }
-- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor
"Keith Patrick" <ri************ *******@nospamh otmail.com> wrote in message news:uK******** ********@TK2MSF TNGP11.phx.gbl. .. I've seen this come up before, but in my case, things are a little more complex, and I'm having a tough time figuring out how to set an element name that works. I have a configuration file that is my serialized object
(I'm using a customer deserializer to add some more XAML-like capabilities): <AppConfigObjec t> <RuntimeType:Ke rnel xmlns:RuntimeTy pe="MyNamespace .DefaultKernel, Kernel"/> </AppConfigObject >
public class AppConfigObject { [XmlElement] public Kernel {...} }
Problem I have is deserializing the child node <Kernel> because it
always throws an error about "<Kernel xmlns='MyNamesp ace.DefaultKern el,
Kernel'> was not expected.". I'm hoping that it's just something I'm missing
(I've tried several combinations of element names and defaultNamespac es) and it's not that what I am trying is not possible.
The thing is, I can't set it like that in the class, because the Kernel
property is of type "BaseKernel ", of which "DefaultKer nel" is a subclass
(this is basically a new serializer that supports concrete implementations
of abstract properties and list items). I tried also setting
defaultNamespac e in my serializer, but the problem there is that I need to
set defautlNamespac e *and* default element name in teh XmlRootAttribut e,but
I can't set both without also having to provide some other params (the last
ctor for that attribute) that I cannot pass in as null, as it throws an
exception in XRA.
The way I think I am going to go is to declare my stuff like this:
<AppConfigObjec t>
<Kernel>
<MyNamespace.De faultKernel Name="..." Attr2="..."/>
</Kernel>
</AppConfigObject >
and just go through every assembly in the appdomain to look for
MyNamespace.Def aultKernel (it's a somewhat slow process, as it's heavy into
reflection and has to iterate through several assemblies, but this stuff is
all part of startup and not regular operation. Another downside is that I
can't have two assemblies in the appdomain with the same namespace + class,
but I can live with that limitation until I replace the config format with
XAML snippets)
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:O9******** ******@TK2MSFTN GP11.phx.gbl... Your XML document states that the <Kernel> element belongs to the "MyNamespace.De faultKernel, Kernel" namespace, but your serialization attribute does not declare the namespace.
Try:
public class AppConfigObject { [XmlElement(Name space="MyNamesp ace.DefaultKern el, Kernel")] public Kernel {...} }
-- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor
"Keith Patrick" <ri************ *******@nospamh otmail.com> wrote in message news:uK******** ********@TK2MSF TNGP11.phx.gbl. .. I've seen this come up before, but in my case, things are a little more complex, and I'm having a tough time figuring out how to set an element name that works. I have a configuration file that is my serialized object
(I'm using a customer deserializer to add some more XAML-like capabilities): <AppConfigObjec t> <RuntimeType:Ke rnel xmlns:RuntimeTy pe="MyNamespace .DefaultKernel, Kernel"/> </AppConfigObject >
public class AppConfigObject { [XmlElement] public Kernel {...} }
Problem I have is deserializing the child node <Kernel> because it
always throws an error about "<Kernel xmlns='MyNamesp ace.DefaultKern el,
Kernel'> was not expected.". I'm hoping that it's just something I'm missing
(I've tried several combinations of element names and defaultNamespac es) and it's not that what I am trying is not possible.
I dunno what I was thinking with that ctor stuff. I can set the namespace
independently, and it works (at least without the Runtime: stuff):
<Kernel xmlns="MyNamesp ace.DefaultKern el, Kernel"/>
will deserialize just fine as long as my XmlRootAttribut e has a name of
"Kernel" and a namespace of "MyNamespace.De faultKernel, Kernel", which is
basically a non-metadata way of doing what you suggested. Thanks for
steering me in the right direction
I dunno what I was thinking with that ctor stuff. I can set the namespace
independently, and it works (at least without the Runtime: stuff):
<Kernel xmlns="MyNamesp ace.DefaultKern el, Kernel"/>
will deserialize just fine as long as my XmlRootAttribut e has a name of
"Kernel" and a namespace of "MyNamespace.De faultKernel, Kernel", which is
basically a non-metadata way of doing what you suggested. Thanks for
steering me in the right direction
Would attaching multiple XmlElement attributes to the property work better
for you? Something like:
public class AppConfigObject {
[XmlElement(type of(BaseKernel), Namespace="MyNa mespace.BaseKer nel,
Kernel")]
[XmlElement(type of(DefaultKerne l), Namespace="MyNa mespace.Default Kernel,
Kernel")]
public Kernel {...}
}
This avoids messing with XmlRoot attributes altogether.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Keith Patrick" <ri************ *******@nospamh otmail.com> wrote in message
news:u8******** ********@tk2msf tngp13.phx.gbl. .. I dunno what I was thinking with that ctor stuff. I can set the namespace independently, and it works (at least without the Runtime: stuff):
<Kernel xmlns="MyNamesp ace.DefaultKern el, Kernel"/> will deserialize just fine as long as my XmlRootAttribut e has a name of "Kernel" and a namespace of "MyNamespace.De faultKernel, Kernel", which is basically a non-metadata way of doing what you suggested. Thanks for steering me in the right direction
Would attaching multiple XmlElement attributes to the property work better
for you? Something like:
public class AppConfigObject {
[XmlElement(type of(BaseKernel), Namespace="MyNa mespace.BaseKer nel,
Kernel")]
[XmlElement(type of(DefaultKerne l), Namespace="MyNa mespace.Default Kernel,
Kernel")]
public Kernel {...}
}
This avoids messing with XmlRoot attributes altogether.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Keith Patrick" <ri************ *******@nospamh otmail.com> wrote in message
news:u8******** ********@tk2msf tngp13.phx.gbl. .. I dunno what I was thinking with that ctor stuff. I can set the namespace independently, and it works (at least without the Runtime: stuff):
<Kernel xmlns="MyNamesp ace.DefaultKern el, Kernel"/> will deserialize just fine as long as my XmlRootAttribut e has a name of "Kernel" and a namespace of "MyNamespace.De faultKernel, Kernel", which is basically a non-metadata way of doing what you suggested. Thanks for steering me in the right direction
I'm not able to do that because I need to allow for any subclass of
BaseKernel to be used. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JohnnySparkles |
last post by:
Hi everyone,
I'm currently writing an application which uses the XmlSerializer class to
serialize/deserialize objects to/from xml.
Now when deserializing an XmlDocument back into the object, I'm using the
System::Type::GetType(String* typeName) to create a Type* needed to construct
the XmlSerializer.
The typeName argument is taken from the XmlDocument and consists of the
|
by: Keith Patrick |
last post by:
I've seen this come up before, but in my case, things are a little more
complex, and I'm having a tough time figuring out how to set an element name
that works. I have a configuration file that is my serialized object (I'm
using a customer deserializer to add some more XAML-like capabilities):
<AppConfigObject>
<RuntimeType:Kernel xmlns:RuntimeType="MyNamespace.DefaultKernel, Kernel"/>
</AppConfigObject>
public class AppConfigObject {
|
by: Simon Gregory |
last post by:
I'm trying to override the default elementnames in the (seemingly)
simple case of serializing an array of GUIDs into XML. Here's the
basic code I started with:
Dim arrGuids(3) as Guid
arrGuids(0) = Guid.NewGuid
arrGuids(1) = Guid.NewGuid
arrGuids(2) = Guid.NewGuid
|
by: ashoksrini |
last post by:
Hi All,
I have the below requirement and would like to get some feeback from the
group on the best way to implement:
1. I have WSDL defined exposing few web services.
2. We dont have a requirement to have a server web service class. (reasons
below)
3. I want to develop something like this - when client makes a web service
call, on the server I can intercept the SOAP message (XML doc itself),
|
by: Keith Patrick |
last post by:
Could someone explain to me the ramifications of declaring
XmlRoot("namespace") on a series of classes in which one or more are
aggregates within another? I have a bunch of classes with a single
namespace declared as XmlRoots, but the serialized XML that is outputted
puts those namespace decls on different elements depending on whether or not
the root element is one of the classes or an array of that class.
Basically, if it's an array,...
| |
by: Vinny_Davis |
last post by:
Hello -
I have a complex object which I am exposing over a webservice on our
intranet. In Visual studio 2003 I had to add
"" just above my complex object in Reference.CS under
Reference.map area. After I did this on the client side, I was able to
load the full object including children also.
Now I am consuming the same webservice in VS 2005 developed asp.net
application. And it looks like VS 2005 still did not fix the issue of...
|
by: groovyghoul |
last post by:
Hi
I have the following XML file:
===========================================================
<?xml version="1.0" encoding="UTF-16"?>
<Policy xmlns="http://tempuri.org/richard.xsd">
<TransType />
<LOB />
<Name>
<FirstName />
|
by: dizzy |
last post by:
Hi
I wonder if this code is standard conformant and should work on all
conformant implementations (for some type T):
1: void* mem = ::operator new(sizeof(T));
2: T* p = new(mem) T(args...);
3: delete p;
line 2 I know it should be fine because global operator new should return
|
by: Andrew |
last post by:
Hi,
I am using DataContractJsonSerializer to deserialize JSON string in C#
objects but I am having a problem.
Suppose I have a class:
class Item
{
public ItemId Id { get; set; }
|
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: 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,...
| |
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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |