Click here to Skip to main content
15,749,066 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I'm trying to read from a webforms app in C# the BODY of the messages from the transactional system dead letter queue pre-defined by MSMQ The messages can be read ok, but when trying to read the Body property I get an exception.: InvalidOperationException, with the message {"Cannot deserialize the message passed as an argument. Cannot recognize the serialization format."}

Context: the messages I'm trying to read from the dead letter queue are messages generated via WFC service invocation using netMSMQBinding, so they are not "ordinary" messages. Our customer needs an app that allows a system administrator to read the contents of the message from the dead letter queue (that would need extra parsing of the message body I guess, IF I can finally read the darn body :-) ), maybe change the original contents of the body, and then re-enquee (or delete) the message to it's original queue (or a modified copy of the original message).

I need a PoisonQueueMessage body in XML format.I tired to serialize queuemessage body but it was give an XML Exception Error Is there any way to get a body of message?
I used this Code:
public static string SerializeToString(object obj)
string xmlString = string.Empty;
StringWriter writer = null;
XmlSerializer serializer = new XmlSerializer(obj.GetType());

using (writer = new StringWriter())
serializer.Serialize(writer, obj);
xmlString = writer.ToString();
if(writer != null)
return xmlString;
Updated 20-Feb-13 6:32am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900