0

I am trying to use AutoMapper to map Microsoft.ServiceBus.Messaging.BrokeredMessage to a lightweight DTO. I have the following code:

Mapper.CreateMap<BrokeredMessage, QueueMessage>()
            .ForMember(dest=>dest.ID, src=>src.MapFrom(x=>x.SequenceNumber));

But this is producing an exception:

An exception of type 'System.ArgumentException' occurred in System.Core.dll but was not handled in user code. Additional information: Method T GetBodyT is a generic method definition

Would be grateful for any suggestions.

Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
user2984303
  • 320
  • 2
  • 9
  • what does the definitions of BrokeredMessage and QueueMessage look like? – tdbeckett Oct 07 '14 at 17:23
  • BrokeredMessage is just Microsoft.ServiceBus.Messaging.BrokeredMessage QueueMessage is simple class `public class QueueMessage { public long SequenceNo { get; set; } public string Path { get; set; } public string Body { get; set; } }` – user2984303 Oct 08 '14 at 11:56
  • I think you're looking in the wrong place. With the info on hand, I would say the exception is being generated when you call an instance BrokeredMessage. See the provided links. – tdbeckett Oct 08 '14 at 12:43
  • http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage.aspx – tdbeckett Oct 08 '14 at 12:43
  • http://msdn.microsoft.com/en-us/library/hh144211.aspx – tdbeckett Oct 08 '14 at 12:44
  • http://msdn.microsoft.com/en-us/library/hh125098.aspx – tdbeckett Oct 08 '14 at 12:46
  • Also the Queue message doesn't have an ID property in the definition you provided. – tdbeckett Oct 08 '14 at 13:25
  • Also also your classes don't seem to have a 1 to 1 match on properties. I don't remember the exception thrown for it, but automapper must define each property it uses. You will need to handle that, or if you don't want those properties to be dealt with by auto mapper you need to ignore them. http://stackoverflow.com/questions/4052579/automapper-how-to-ignore-property-in-source-item-that-does-not-exist-in-destinat – tdbeckett Oct 08 '14 at 15:41

0 Answers0