[Mono-list] WCF datacontract

mauzik mauzik at centrum.cz
Wed Sep 4 20:50:15 UTC 2013


I have configured WCF via TCP. It works perfect under .NET, but under MONO
appears following exception
Dante.Tests.WcfTcp.AuthenticationProviderTests.AuthenticationShouldWorkWithViaWcfTcp
: 

System.Runtime.Serialization.SerializationException : Type
'Dante.Contracts.Authentication.PinAuthenticationCommand' is 

unexpected. The type should either be registered as a known type, or
DataContractResolver should be used.
at System.Runtime.Serialization.DataContractSerializer.WriteStartObject
(System.Xml.XmlDictionaryWriter writer, 

System.Object graph) [0x00282] in 

/opt/mono/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:513
at 

System.Runtime.Serialization.XmlObjectSerializer.WriteObject
(System.Xml.XmlDictionaryWriter writer, System.Object graph) 

[0x00000] in 

/opt/mono/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:113
at 

System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.WriteMessagePart 

(System.Xml.XmlDictionaryWriter writer,
System.ServiceModel.Description.MessageBodyDescription desc, 

System.ServiceModel.Description.MessagePartDescription partDesc,
System.Object obj) [0x00049] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:503
at 

System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.OnWriteBodyContents 

(System.Xml.XmlDictionaryWriter writer) [0x00091] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:488
at 

System.ServiceModel.Channels.BodyWriter.WriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00000] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs:57
at 

System.ServiceModel.Channels.SimpleMessage.OnWriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00000] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:331
at 

System.ServiceModel.Channels.Message.WriteBodyContents
(System.Xml.XmlDictionaryWriter writer) [0x00022] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:183
at 

System.ServiceModel.Channels.Message.WriteBody
(System.Xml.XmlDictionaryWriter writer) [0x0001c] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:168
at 

System.ServiceModel.Channels.Message.OnWriteMessage
(System.Xml.XmlDictionaryWriter writer) [0x00065] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:293
at 

System.ServiceModel.Channels.Message.WriteMessage
(System.Xml.XmlDictionaryWriter writer) [0x00026] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:195
at 

System.ServiceModel.Channels.BinaryMessageEncoder.WriteMessage
(System.ServiceModel.Channels.Message message, 

System.IO.Stream stream) [0x0002a] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoder.cs:124
at 

System.ServiceModel.Channels.NetTcp.TcpBinaryFrameManager.WriteSizedMessage
(System.ServiceModel.Channels.Message message) 

[0x0006c] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs:440
at 

System.ServiceModel.Channels.NetTcp.TcpDuplexSessionChannel.Send
(System.ServiceModel.Channels.Message message, TimeSpan 

timeout) [0x0008e] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpDuplexSessionChannel.cs:153
at 

System.ServiceModel.MonoInternal.ClientRuntimeChannel.RequestCorrelated
(System.ServiceModel.Channels.Message msg, 

TimeSpan timeout, IOutputChannel channel) [0x00006] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:585
at 

System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) 

[0x00019] in
/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:576
at 

System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od, 

System.Object[] parameters) [0x00066] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:531
at 

System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess
(System.Reflection.MethodBase method, System.String 

operationName, System.Object[] parameters) [0x00038] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:496
at 

System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process
(System.Reflection.MethodBase method, System.String 

operationName, System.Object[] parameters) [0x0001c] in 

/opt/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:477


My data class is:

    [DataContract]
    public class PinAuthenticationCommand : BaseAuthenticationCommand
    {
        [DataMember]
        public string Pin { get; private set; }

        public PinAuthenticationCommand(string pin)
        {
            Pin = pin;
        }

        public override AuthenticationStatus Execute()
        {
            if (string.IsNullOrEmpty(Pin))
            {
                return AuthenticationStatus.Rejected;
            }

            return AuthenticationStatus.Accepted;
        }
    }
}

and BaseAuthenticationCommand:

   [DataContract]
    public abstract class BaseAuthenticationCommand : IAuthenticationCommand
    {
        public virtual AuthenticationStatus Execute()
        {
            return AuthenticationStatus.Accepted;
        }
    }


I do not know how I should resolve it. I think it is not caused by Mono
missing feature. I tried add [KnownType(typeof(string))], but it does not
work - in my opinion it is absurdity. String is not third party class. I do
not have any other ideas. I will be grateful for your help.



--
View this message in context: http://mono.1490590.n4.nabble.com/WCF-datacontract-tp4660758.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list