Questions tagged [xmlinclude]

12 questions
26
votes
4 answers

How to add XmlInclude attribute dynamically

I have the following classes [XmlRoot] public class AList { public List ListOfBs {get; set;} } public class B { public string BaseProperty {get; set;} } public class C : B { public string SomeProperty {get; set;} } public class…
Anindya Chatterjee
  • 5,824
  • 13
  • 58
  • 82
7
votes
2 answers

System.InvalidOperationException: The type [XYZ] may not be used in this context. BUG Confirmed

I'm at my wits end on this one. I occasionally get the error above from my .Net 2.0 asmx web service. I've got the proper XmlInclude() in place, and it only appears sometimes - when I rebuild and update the site, it may show up, it may not, no rhyme…
Jerod Venema
  • 44,124
  • 5
  • 66
  • 109
3
votes
2 answers

Any way to specify the XML string used in xsi:type=""?

I have a hierarchy of classes that are serialised to XML using XMLSerialiser. To do this I am declaring all the concrete types with [XmlInclude]. eg. [XmlInclude(typeof(Derived))] public class Base { } public class Derived : Base { } An…
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103
1
vote
1 answer

Way to XmlInclude automatically for all derived classes?

Apparently XmlSerializer works smoothly for objects if the instances are not derived, otherwise I'd have to explicitly apply an attribute to include specific derived classes onto the base class. I have around 50+ derived classes and possibly more in…
chaz
  • 568
  • 1
  • 8
  • 22
1
vote
1 answer

C# XmlSerializer's XmlInclude equivalent in Java

I looking for a Java annotation which does the same like XmlInclude does in C#. I get a XML structure over a socket. The structure looks like this:
Hackeris
  • 11
  • 2
1
vote
0 answers

System.InvalidOperationException: 'The type System.Collections.Generic.List`1 may not be used in this context.'

I have an asmx which returns data to a client. In the asmx I have the following method : [WebMethod] [XmlInclude(typeof(CustomField))] public List GetData(InitializeRequest request) { return…
Bart Schelkens
  • 1,235
  • 4
  • 21
  • 45
1
vote
1 answer

C# Exception when trying to serialize a dynamic derived object

I have the following classes: [XmlInclude(typeof(Cat))] [XmlInclude(typeof(Dog))] [XmlInclude(typeof(Cow))] [Serializable] public abstract class Animal { public string Name { get; set; } } public class Cow : Animal { public Cow(string name)…
MaorK84
  • 11
  • 3
0
votes
1 answer

How to use XmlInclude to specify types dynamically?

I have these classes which I use: namespace defaultNamespace { ... public class DataModel { } public class Report01 {get; set;} public class Report02 {get; set;} } And I have a method that creates the XML…
Onur Adıgüzel
  • 35
  • 3
  • 10
0
votes
1 answer

Can't find xml fragment

I am trying to include xml fragment file in xml file and accessing parent.xml from java code. Java code look like: DocumentBuilderFactory dfactory =…
Kaustubh Najan
  • 879
  • 1
  • 7
  • 8
0
votes
2 answers

Cannot Access Views inside Included layout

I am using an "include" layout that is part of a fragment. Here is where I inflate the layout that includes the "include" (and below it is the layout itself): @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle…
taraloca
  • 9,077
  • 9
  • 44
  • 77
0
votes
2 answers

xml serialization and Inherited Types

I got the error "{"The type Device1 was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."}" Currently I have: public abstract class Device { .. } public class Device1 : Device { ...…
user1902346
  • 799
  • 1
  • 12
  • 21