Click here to Skip to main content
15,887,776 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Usage of generics in .net projects Pin
Abhinav S12-May-10 20:04
Abhinav S12-May-10 20:04 
AnswerRe: Usage of generics in .net projects Pin
Peace ON12-May-10 21:52
Peace ON12-May-10 21:52 
GeneralRe: Usage of generics in .net projects Pin
kalyan_vb13-May-10 7:10
kalyan_vb13-May-10 7:10 
AnswerRe: Usage of generics in .net projects Pin
Peace ON13-May-10 21:58
Peace ON13-May-10 21:58 
AnswerRe: Usage of generics in .net projects Pin
PIEBALDconsult13-May-10 4:11
mvePIEBALDconsult13-May-10 4:11 
QuestionR6002 - floating point support not loaded Pin
marca29211-May-10 21:50
marca29211-May-10 21:50 
AnswerRe: R6002 - floating point support not loaded Pin
Richard MacCutchan11-May-10 22:07
mveRichard MacCutchan11-May-10 22:07 
QuestionNServiceBus serialization of inheritanced Type issue [modified] Pin
Tiju John11-May-10 1:04
Tiju John11-May-10 1:04 
Hi Guys,

for the context setting, I am exchanging messages between my nServiceBus client and nSerivceBus server. its is the namespace xyz.Messages and and a class, Message : IMessage

I have more messages that are in the other dlls, like xyz.Messages.Domain1, xyz.Messages.Domain2, xyz.Messages.Domain3.
and messages that derive form that base message, Message.

I have the endpoints defined as like :

at client
<UnicastBusConfig>
 <MessageEndpointMappings>
    <add Messages="xyz.Messages" Endpoint="xyzServerQueue" />
    <add Messages="xyz.Messages.Domain1" Endpoint="xyzServerQueue" />
    <add Messages="xyz.Messages.Domain2" Endpoint="xyzServerQueue" />
  </MessageEndpointMappings>
</UnicastBusConfig>




at Server
<UnicastBusConfig>
 <MessageEndpointMappings>
   <add Messages="xyz.Messages" Endpoint="xyzClientQueue" />
   <add Messages="xyz.Messages.Domain1" Endpoint="xyzClientQueue" />
   <add Messages="xyz.Messages.Domain2" Endpoint="xyzClientQueue" />
 </MessageEndpointMappings>
</UnicastBusConfig>




and the bus initialized as
IBus serviceBus = Configure.With()
    .SpringBuilder()
    .XmlSerializer()
    .MsmqTransport()
    .UnicastBus()
    .LoadMessageHandlers()
    .CreateBus()
    .Start();



now when i try sending instance of Message type or any type derived types of Message, it successfully sends the message over and at the server, i get the proper type.

eg.

Message message= new Message();
Bus.Send(message); // works fine, transfers Message type
message = new MessageDerived1();
Bus.Send(message); // works fine, transfers MessageDerived1 type
message = new MessageDerived2();
Bus.Send(message); // works fine, transfers MessageDerived2 type


My problem arises when any type, say MessageDerived1, contains a member variable of type Message, and when i assign it to a derived type, the type is not properly transferred over the wire. It transfers only as Message type, not the derived type.

public class MessageDerived2 : Message
{
  public Message message;
}

MessageDerived2 messageDerived2= new MessageDerived2();
messageDerived2.message = new MessageDerived1();
message = messageDerived2;
Bus.Send(message); // incorrect behaviour, transfers MessageDerived2 correctly, but looses type of  MessageDerived2.Message (it deserializes as Message type, instead of MessageDerived1)


any help is strongly appreciated.


Thanks
TJ

modified on Wednesday, May 12, 2010 4:02 AM

QuestionBuilt-in graphic images for .Net Pin
Don Heath10-May-10 11:45
Don Heath10-May-10 11:45 
AnswerRe: Built-in graphic images for .Net Pin
Henry Minute11-May-10 1:49
Henry Minute11-May-10 1:49 
GeneralRe: Built-in graphic images for .Net Pin
Don Heath11-May-10 2:40
Don Heath11-May-10 2:40 
GeneralRe: Built-in graphic images for .Net Pin
Henry Minute11-May-10 2:46
Henry Minute11-May-10 2:46 
QuestionDisable BindingSource.DataError event? Pin
Alan N10-May-10 10:37
Alan N10-May-10 10:37 
QuestionCoding conventions Pin
Simon_Whale10-May-10 5:38
Simon_Whale10-May-10 5:38 
AnswerRe: Coding conventions Pin
Not Active10-May-10 6:57
mentorNot Active10-May-10 6:57 
AnswerRe: Coding conventions Pin
Luc Pattyn10-May-10 8:02
sitebuilderLuc Pattyn10-May-10 8:02 
AnswerRe: Coding conventions Pin
Abhinav S10-May-10 16:59
Abhinav S10-May-10 16:59 
AnswerRe: Coding conventions Pin
PIEBALDconsult11-May-10 4:04
mvePIEBALDconsult11-May-10 4:04 
GeneralRe: Coding conventions Pin
Simon_Whale11-May-10 4:08
Simon_Whale11-May-10 4:08 
QuestionLooking for a localization related codeproject article/tool Pin
berntie10-May-10 2:01
berntie10-May-10 2:01 
AnswerRe: Looking for a localization related codeproject article/tool Pin
Peace ON10-May-10 2:16
Peace ON10-May-10 2:16 
GeneralRe: Looking for a localization related codeproject article/tool Pin
berntie10-May-10 2:30
berntie10-May-10 2:30 
AnswerRe: Looking for a localization related codeproject article/tool Pin
Abhinav S10-May-10 4:08
Abhinav S10-May-10 4:08 
GeneralRe: Looking for a localization related codeproject article/tool Pin
berntie10-May-10 4:15
berntie10-May-10 4:15 
AnswerRe: Looking for a localization related codeproject article/tool Pin
Abhinav S10-May-10 4:21
Abhinav S10-May-10 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.