[Mono-bugs] [Bug 403829] New: Cannot deserialize an array of base types that contains instances of derived types
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Jun 25 13:16:17 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=403829
Summary: Cannot deserialize an array of base types that contains
instances of derived types
Product: Mono: Class Libraries
Version: SVN
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: WCF
AssignedTo: noaml at mainsoft.com
ReportedBy: taktaktaktaktaktaktaktaktaktak at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
One cannot return an array of base types that contains instances of derived
types from an OperationContract method.
If I have data contracts:
[DataContract]
[KnownType(typeof(DerivedContract))]
public class BaseContract {
[DataMember]
string name;
}
[DataContract]
public class DerivedContract: BaseContract {
[DataMember]
bool blah;
}
a service contract:
[ServiceContract]
public interface IMyServiceContract
{
[OperationContract]
BaseContract[] foo();
}
a service implementation:
public BaseContract[] foo() {
return new BaseContract[]{ new DerivedContract() };
}// foo
and a client:
BaseContract[] blah = s.foo();
System.Console.WriteLine("Got {0}", blah[0].GetType().ToString());
The expected result is:
Got DerivedContract.
(This is the result on MS.NET, btw)
Executing the client gives:
Unhandled Exception: System.Runtime.Serialization.SerializationException:
Unknown type Contracts.BaseContract is used for DataContract. Any derived types
of a data contract or a data member should be added to KnownTypes.
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeContent
(System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader
reader) [0x00076] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:139
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Type type, System.Xml.XmlReader reader) [0x000d5] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:111
at System.Runtime.Serialization.CollectionTypeMap.DeserializeContent
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0004c]
in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:476
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeContent
(System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader
reader) [0x0006d] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:138
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Type type, System.Xml.XmlReader reader) [0x000d5] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:111
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Xml.XmlReader reader, System.Type type,
System.Runtime.Serialization.KnownTypeCollection knownTypes,
IDataContractSurrogate surrogate, System.String name, System.String Namespace,
Boolean verifyObjectName) [0x0001a] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:53
at System.Runtime.Serialization.DataContractSerializer.ReadObject
(System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) [0x00024] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:269
at System.Runtime.Serialization.XmlObjectSerializer.ReadObject
(System.Xml.XmlDictionaryReader reader) [0x00000] in
/home/lbar4/dev/olive/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:77
at
System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts
(System.ServiceModel.Description.MessageDescription md,
System.ServiceModel.Channels.Message message) [0x000b8] in
/home/lbar4/dev/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:349
at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply
(System.ServiceModel.Channels.Message message, System.Object[] parameters)
[0x00048] in
/home/lbar4/dev/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:165
at System.ServiceModel.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od, System.Object[]
parameters) [0x0016a] in
/home/lbar4/dev/olive/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:374
at System.ServiceModel.ClientRuntimeChannel.Process
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00015] in
/home/lbar4/dev/olive/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:226
at __clientproxy_IMyServiceContract.foo () [0x00000]
at OlivePolymorphTest.MyClient.Main (System.String[] args) [0x00071] in
/home/lbar4/dev/OlivePolymorphTest/OlivePolymorphTest/MyClient.cs:26
I'm using olive r106446.
--
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