Reputation: 77
How can we pass different Object from a given function.
static public void SerializeToXML(FbTextView p)
{
XmlSerializer serializer = new XmlSerializer(typeof(FbTextView));
TextWriter textWriter = new StreamWriter(@"D:\movie.xml");
serializer.Serialize(textWriter, p);
textWriter.Close();
}
now the problem is that when I try to pass two or more then two objects like this:
static public void SerializeToXML(FbTextView p,FbTextField q)
{
XmlSerializer serializer = new XmlSerializer(typeof(FbTextView));
XmlSerializer Serializer = new XmlSerializer(typeof(FbTextField));
TextWriter textWriter = new StreamWriter(@"D:\movie.xml");
serializer.Serialize(textWriter, p);
textWriter.Close();
}
it throw error: XMLParse Exception Was unhandled. and the inner exception is : "There was an error reflecting type 'FBformBuilder.FbTextField" thanks !
Upvotes: 2
Views: 1019
Reputation: 6301
inner exception:
The type for XmlElement may not be specified for primitive types.
Remove [XmlElement(Type)]
attribute from FbTextField
Value
field
Upvotes: 0
Reputation: 1063569
The problem will be fully detailed in the inner exceptions; try:
try {
// ... your code
} catch(Exception ex) {
while(ex != null) {
Trace.WriteLine(ex.Message);
ex = ex.InnerException;
}
throw;
}
then look at all the .Message
s that get logged. One of these will tell you the exact problem. For example, it could be something like:
or something similar
Upvotes: 1