[Mono-bugs] [Bug 74922][Wis] Changed - XmlSerializer: "type not
expected" message could be more informative
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun May 22 18:40:17 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by bmaurer at users.sf.net.
http://bugzilla.ximian.com/show_bug.cgi?id=74922
--- shadow/74922 2005-05-12 10:21:01.000000000 -0400
+++ shadow/74922.tmp.13556 2005-05-22 18:40:17.000000000 -0400
@@ -11,13 +11,13 @@
AssignedTo: mono-bugs at ximian.com
ReportedBy: ricardo.gladwell at btinternet.com
QAContact: mono-bugs at ximian.com
TargetMilestone: ---
URL:
Cc:
-Summary: Type not expected error message thrown by XmlSerializer.Serialize not informative enough
+Summary: XmlSerializer: "type not expected" message could be more informative
Description of Problem: The error message thrown (see stacktrace.txt
attached) when the System.Xml.Serialization.XmlSerializer class serializes
an object graph does not contain enough information to verify the object in
the graph that is causnig the error.
@@ -44,6 +44,65 @@
------- Additional Comments From lluis at ximian.com 2005-05-12 10:12 -------
Which kind of additional information do you think it would be helpful?
------- Additional Comments From ricardo.gladwell at btinternet.com 2005-05-12 10:21 -------
The reference to the object that returned the unexpected type, the
method or attribute name that returned the unexpected type, for example.
+
+------- Additional Comments From bmaurer at users.sf.net 2005-05-22 18:40 -------
+The MSFT generated message isn't that much better:
+
+Unhandled Exception: System.InvalidOperationException: There was an
+error generating the XML document. --->
+System.InvalidOperationException: The type Site may not be used in
+this context.
+ at
+System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
+name, String ns, Object o, Boolean xsiType)
+ at
+Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_Object(String
+n, String ns, Object o, Boolean isNullable, Boolean needType)
+ at
+Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Configuration(String
+n, String ns, Configuration o, Boolean isNullable, Boolean needType)
+ at
+Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3_Configuration(Object
+o)
+ --- End of inner exception stack trace ---
+ at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter
+xmlWriter, Object o, XmlSerializerNamespaces namespaces, String
+encodingStyle)
+ at System.Xml.Serialization.XmlSerializer.Serialize(Stream stream,
+Object o)
+ at Test.Main()
+
+The compilation does help out a little bit.
+
+when Mono compiles the thing, it also gives a bit more of a helpful
+method:
+
+Unhandled Exception: System.InvalidOperationException: The type Site
+was not expected. Use the XmlInclude or SoapInclude attribute to
+specify types that are not known statically.
+in <0x0026b>
+System.Xml.Serialization.XmlSerializationWriter:WriteTypedPrimitive
+(System.String name, System.String ns, System.Object o, Boolean xsiType)
+in <0x000ee>
+Mono.GeneratedSerializers.Literal.GeneratedWriter:WriteObject_anyType
+(System.Object ob, System.String element, System.String namesp,
+Boolean isNullable, Boolean needType, Boolean writeWrappingElem)
+in <0x0014e>
+Mono.GeneratedSerializers.Literal.GeneratedWriter:WriteObject_Configuration
+(.Configuration ob, System.String element, System.String namesp,
+Boolean isNullable, Boolean needType, Boolean writeWrappingElem)
+in <0x00058>
+Mono.GeneratedSerializers.Literal.GeneratedWriter:WriteRoot_Configuration
+(System.Object o)
+in <0x00000> <unknown method>
+in (wrapper managed-to-native)
+System.Reflection.MonoMethod:InternalInvoke (object,object[])
+in <0x0006f> System.Reflection.MonoMethod:Invoke (System.Object obj,
+BindingFlags invokeAttr, System.Reflection.Binder binder,
+System.Object[] parameters, System.Globalization.CultureInfo culture)
+
+A way to fix this for the interp case might be to try { } catch {} and
+add information, then make the old exception an inner exception.
More information about the mono-bugs
mailing list