Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET4 XmlReader serialization , +
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 Smile | :) ), 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;
try
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
 
using (writer = new StringWriter())
{
serializer.Serialize(writer, obj);
xmlString = writer.ToString();
}
}
finally
{
if(writer != null)
{
writer.Close();
}
}
return xmlString;
}
Posted 20-Feb-13 6:04am
Edited 20-Feb-13 6:32am
v3

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

  Print Answers RSS
0 OriginalGriff 405
1 Peter Leow 225
2 Sergey Alexandrovich Kryukov 210
3 Maciej Los 195
4 DamithSL 174


Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid