C
Chizl
On the MQReceiveCompleted method below, I get an error "Name cannot begin
with the '.' character, hexadecimal value 0x00. Line 1, position 40."..
This data is XML that I'm putting into this queue.
---------
<?xml version=""1.0""
encoding=""utf-8""?><DATA><FIELD1>CHIZL</FIELD1><FIELD2>DA
MAN</FIELD2></DATA>
---------
Methods
---------------------
public void SetupMSMQ()
{
String szMQPath = @".\private$\TestQueue";
if (!MessageQueue.Exists(szMQPath))
MessageQueue.Create(szMQPath);
//setup MQ Request Path
MessageQueue mq = new MessageQueue(szMQPath);
//format of message will be XML
mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(String) });
//vs..
//((XmlMessageFormatter)mq.Formatter).TargetTypeNames = new string[] {
"Data" };
//setup async call
mq.ReceiveCompleted += new
ReceiveCompletedEventHandler(MQReceiveCompleted);
//callback ready
mq.BeginReceive();
...
...
}
private static void MQReceiveCompleted(Object source,
ReceiveCompletedEventArgs asyncResult)
{
//connect to the queue.
MessageQueue mq = (MessageQueue)source;
//end the asynchronous Receive operation.
System.Messaging.Message m = mq.EndReceive(asyncResult.AsyncResult);
//display message information on the screen.
String szXML = (String)m.Body; //Fails
....
}
with the '.' character, hexadecimal value 0x00. Line 1, position 40."..
This data is XML that I'm putting into this queue.
---------
<?xml version=""1.0""
encoding=""utf-8""?><DATA><FIELD1>CHIZL</FIELD1><FIELD2>DA
MAN</FIELD2></DATA>
---------
Methods
---------------------
public void SetupMSMQ()
{
String szMQPath = @".\private$\TestQueue";
if (!MessageQueue.Exists(szMQPath))
MessageQueue.Create(szMQPath);
//setup MQ Request Path
MessageQueue mq = new MessageQueue(szMQPath);
//format of message will be XML
mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(String) });
//vs..
//((XmlMessageFormatter)mq.Formatter).TargetTypeNames = new string[] {
"Data" };
//setup async call
mq.ReceiveCompleted += new
ReceiveCompletedEventHandler(MQReceiveCompleted);
//callback ready
mq.BeginReceive();
...
...
}
private static void MQReceiveCompleted(Object source,
ReceiveCompletedEventArgs asyncResult)
{
//connect to the queue.
MessageQueue mq = (MessageQueue)source;
//end the asynchronous Receive operation.
System.Messaging.Message m = mq.EndReceive(asyncResult.AsyncResult);
//display message information on the screen.
String szXML = (String)m.Body; //Fails
....
}