Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

MSMQ Formatter and XmlMessageFormatter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chizl - 28 Feb 2008 03:43 GMT
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
   ....
}

Signature

/*Chizl*/

Chizl - 28 Feb 2008 03:49 GMT
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?

> On the MQReceiveCompleted method below, I get an error "Name cannot begin
> with the '.' character, hexadecimal value 0x00. Line 1, position 40."..
[quoted text clipped - 44 lines]
>    ....
> }
Mufaka - 28 Feb 2008 05:54 GMT
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.

> 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?
Dan Kelley - 29 Feb 2008 08:57 GMT
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.

> I vaguely recall having to use a BinaryFormatter when reading queue
> items inserted by another language. You can try that and just get the
[quoted text clipped - 3 lines]
> > I noticed in the queue the data is in Unicode.  So how do I get it to write
> > as ASCII?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.