PC Review


Reply
Thread Tools Rate Thread

MSMQ Formatter and XmlMessageFormatter

 
 
Chizl
Guest
Posts: n/a
 
      28th Feb 2008
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*/


 
Reply With Quote
 
 
 
 
Chizl
Guest
Posts: n/a
 
      28th Feb 2008
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" <(E-Mail Removed)> wrote in message
news:%23Q$(E-Mail Removed)...
> 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*/
>



 
Reply With Quote
 
 
 
 
Mufaka
Guest
Posts: n/a
 
      28th Feb 2008
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 With Quote
 
Dan Kelley
Guest
Posts: n/a
 
      29th Feb 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
With MSMQ use the formatter only in the message level Gomez Microsoft C# .NET 0 18th Apr 2010 08:19 PM
MSMQ binding Stop processing after Cluster MSMQ failover Bhavesh Shah Microsoft C# .NET 0 24th Apr 2009 05:02 PM
problems converting C# code to VB.net (MSMQ formatter problem) =?Utf-8?B?Q0xFQVItUkNJQw==?= Microsoft Dot NET 1 12th Sep 2005 07:12 PM
About ViewState and LOS formatter Edward Yang Microsoft ASP .NET 1 22nd Nov 2004 08:07 PM
How can I get the peer's IP when using IIS-hosted remoting with binary formatter and HTTP? Microsoft Dot NET Framework 3 1st Aug 2003 07:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:20 AM.