Message Queues with different message types
问题 I'm investigating Microsoft Message Queues for doing inter-process cross-network messaging. But when I receive a message, I don't know a priori what type of object I'm getting, so the code queue.Formatter = new XmlMessageFormatter(new Type[] { typeof(Wibble) }); can't be applied before I get the message because I don't know if it's a Wibble. So how do I receive different message types? 回答1: You might consider not storing your object in the MSMQ message, but instead putting a reference to it's