MSMQ Formatter and XmlMessageFormatter - CSharp

This is a discussion on MSMQ Formatter and XmlMessageFormatter - CSharp ; 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 ...

+ Reply to Thread
Results 1 to 4 of 4

MSMQ Formatter and XmlMessageFormatter

  1. Default MSMQ Formatter and XmlMessageFormatter

    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
    ....
    }

    --
    /*Chizl*/



  2. Default Re: MSMQ Formatter and XmlMessageFormatter

    I think I know the problem, when I write it to the queue, I'm using VBS and
    I noticed in the queue the data is in Unicode. So how do I get it to write
    as ASCII?

    --
    /*Chizl*/
    "Chizl" <Chizl@NoShitMail.com> wrote in message
    news:%23Q$rmwbeIHA.4144@TK2MSFTNGP05.phx.gbl...
    > 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
    > ....
    > }
    >
    > --
    > /*Chizl*/
    >




  3. Default Re: MSMQ Formatter and XmlMessageFormatter

    I vaguely recall having to use a BinaryFormatter when reading queue
    items inserted by another language. You can try that and just get the
    message body as a string.

    Chizl wrote:
    > I think I know the problem, when I write it to the queue, I'm using VBS and
    > I noticed in the queue the data is in Unicode. So how do I get it to write
    > as ASCII?
    >


  4. Default Re: MSMQ Formatter and XmlMessageFormatter

    For what it is worth I believe you mean the ActiveXFormatter, which should be
    used when receiving messages sent by non .Net applications, for exmaple VB6
    applications.

    "Mufaka" wrote:

    > I vaguely recall having to use a BinaryFormatter when reading queue
    > items inserted by another language. You can try that and just get the
    > message body as a string.
    >
    > Chizl wrote:
    > > I think I know the problem, when I write it to the queue, I'm using VBS and
    > > I noticed in the queue the data is in Unicode. So how do I get it to write
    > > as ASCII?
    > >

    >


+ Reply to Thread