[Mono-bugs] [Bug 404689] Cannot deserialize an array of base types that contains instances of derived types

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jun 27 18:23:36 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=404689

User atsushi at ximian.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=404689#c1


Atsushi Enomoto <atsushi at ximian.com> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
             Status|NEW                                             |RESOLVED
         Resolution|                                                |INVALID




--- Comment #1 from Atsushi Enomoto <atsushi at ximian.com>  2008-06-27 16:23:36 MDT ---
On Sys.Web.Services land, you have to explicitly add [SoapInclude] or
[XmlInclude] attribute onto the base type (MyBase this case) so that it can
handle those derived types.

And that is actually what .NET does. You can check the behavior by:

- go to IIS management console,
- create a virtual directory on a directory that contains this .asmx,
- browse http://localhost/path/to/the/dir/your.asmx ,
- select "blah" method, and click "Invoke" button.

That results in the same error in Mono on .NET:

System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: The type foo+MyDerived was not
expected. Use the XmlInclude or SoapInclude attribute to specify types that are
not known statically.
   at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_MyBase(String
n, String ns, MyBase o, Boolean isNullable, Boolean needType)
   at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3_ArrayOfMyBase(Object
o)
   at
Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfMyBaseSerializer.Serialize(Object
objectToSerialize, XmlSerializationWriter writer)
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o, XmlSerializerNamespaces namespaces)
   at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o)
   at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse
response, Stream outputStream, Object returnValue)
   at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[]
returnValues, Stream outputStream)
   at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
returnValues)
   at System.Web.Services.Protocols.WebServiceHandler.Invoke()


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list