Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
396 stars 141 forks source link

Exception on custom type #518

Closed kvegeta closed 2 years ago

kvegeta commented 2 years ago

Hi there,

i have created a new object named ComplexMessage with some primitive objects inside and decorated with [AmqpContract(Name = "ComplexMessage", Encoding = EncodingType.Map)] and every property with [AmqpMember]. Every time i try to send this object in the queue i always receive this exception message 'The type 'APIProducer.Model.ComplexMessage' is not a valid AMQP type and cannot be encoded.' Any hint? I have also tried with SimpleMap EncodingType with no result.

Thanks a lot to everyone. Alessandro

xinchen10 commented 2 years ago

Which nuget package and version do you use?

It seems like the serialization component is not referenced in your project. On regular .net framework, it is part of the core library and the issue should not happen. But if you use the .net core version, you would need to add a reference to Amqp.Serialization and create a message like this var message = new Message() { BodySection = new AmqpValue<ComplexMessage>(value) };. By doing this the extended serialization component will be loaded. See more details here.