[rabbitmq-discuss] Sending messages with abstract types as properties

kayslay kayode81until at gmail.com
Thu Oct 25 22:36:18 BST 2012


I have a message that I'm sending and one of it's properties is an abstract 
type.  When I send this message I get an exception on the receiver from the 
json serializer:
How am I able to receive a message that has an interface or abstract type 
property, here MyPayload is an abstract class?
Thanks
Exception:
Newtonsoft.Json.JsonSerializationException: Could not create an instance of 
type
 MyNamespace.Payloads.MyPayload. Type
 is an interface or abstract class and cannot be instantated. Path 
'Payload.Id',
 line 1, position 17.
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject
(JsonReader reader, JsonObjectContract objectContract, JsonProperty 
containerMem
ber, JsonProperty containerProperty, String id, Boolean& 
createdFromNonDefaultCo
nstructor)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(Js
onReader reader, Type objectType, JsonContract contract, JsonProperty 
member, Js
onContainerContract containerContract, JsonProperty containerMember, Object 
exis
tingValue)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInte
rnal(JsonReader reader, Type objectType, JsonContract contract, 
JsonProperty mem
ber, JsonContainerContract containerContract, JsonProperty containerMember, 
Obje
ct existingValue)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValu
e(JsonProperty property, JsonConverter propertyConverter, 
JsonContainerContract
containerContract, JsonProperty containerProperty, JsonReader reader, 
Object tar
get)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(
Object newObject, JsonReader reader, JsonObjectContract contract, 
JsonProperty m
ember, String id)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(Js
onReader reader, Type objectType, JsonContract contract, JsonProperty 
member, Js
onContainerContract containerContract, JsonProperty containerMember, Object 
exis
tingValue)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInte
rnal(JsonReader reader, Type objectType, JsonContract contract, 
JsonProperty mem
ber, JsonContainerContract containerContract, JsonProperty containerMember, 
Obje
ct existingValue)
   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Jso
nReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, 
Type
 objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type 
objectT
ype)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type 
type, Jso
nSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, 
JsonSeriali
zerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
   at EasyNetQ.JsonSerializer.BytesToMessage[T](Byte[] bytes)
   at 
EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass1`1.<Subscribe>b__0(Byte[] bod
y, MessageProperties properties, MessageReceivedInfo messageRecievedInfo)
   at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass7.<Subscribe>b__6(String 
consu
merTag, UInt64 deliveryTag, Boolean redelivered, String exchange, String 
routing
Key, IBasicProperties properties, Byte[] body)
   at 
EasyNetQ.QueueingConsumerFactory.HandleMessageDelivery(BasicDeliverEventAr
gs basicDeliverEventArgs)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121025/06fb4d55/attachment.htm>


More information about the rabbitmq-discuss mailing list