Multimobile Development: Building Applications for any Smartphone
MessageQueue
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.csharp.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Paps
I'm trying to test an example of .NET about Queues and it's very simple

MessageQueue MQ = new MessageQueue(".\\MyQueue");
MQ.Send(this, "Hello World");

but when I run it i recive the following error on the Send Method call:
"An unhandled exception of type 'System.Messaging.MessageQueueException'
occurred in system.messaging.dll
Additional information: External component has thrown an exception."

I've installed the Queue Service. (There is another example in the
StartSamples.htm of .NET called "Queued Components" and it's work correctly)

Any Suggestion about using Queues ?

Thanks Paps

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Nicholas Paldino [.NET MVP]
Paps,

Just curious, are you trying to do this in an ASP.NET page?

--
- Nicholas Paldino [.NET MVP]
- Click here to reveal e-mail address

"Paps" <Click here to reveal e-mail address> wrote in message
news:#nhm8Hl1BHA.1228@tkmsftngp04...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Paps
[Original message clipped]

no. I'm trying in a Windows Application.

Paps

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Nicholas Paldino [.NET MVP]
Paps,

Are you sure that the queue in question exists?

--
- Nicholas Paldino [.NET MVP]
- Click here to reveal e-mail address

"Paps" <Click here to reveal e-mail address> wrote in message
news:O55h5vl1BHA.2380@tkmsftngp04...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Willy Denoyette [MVP] (VIP)
The "External component has thrown ..." indicates an error encountered by the MSMQ API, are you sure the MyQueue exists.

Also the ".\\MyQueue" denotes a public queue, when running on W2K, you need to have a DC hosting MSMQ and your workstation must be
part of that domain.
When running XP, MSMQ can directly access queues in the AD.
When running in workgroup mode you can't access public queues, only private queues can be used (.\private$\MyQueue).

Willy.

"Paps" <Click here to reveal e-mail address> wrote in message news:#nhm8Hl1BHA.1228@tkmsftngp04...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Paps
Hi Willy and Nicholas

> The "External component has thrown ..." indicates an error encountered by
the MSMQ API, are you sure the MyQueue exists.

In the Example of .NET http://localhost/quickstart/howto/doc/mqsend.aspx
there is written that if the queue doesn't exist it will be created ! but so
it's not true becouse I create manually the queue and it's work. do you know
why ?

> Also the ".\\MyQueue" denotes a public queue, when running on W2K, you
need to have a DC hosting MSMQ and your workstation must be
[Original message clipped]

I've a Domain and my WS is part of it (XP professional my WS and W2K the
PDC server) but i've installed the MSMQ Server on a W2K Server that itsn't
the Domain controller, The MSMQ server must be the PDC of the Domain ?
It's possible to use a W2K server (not the PDC but a stand alone Server) as
MSQM server and other XP WS as the Message interchange applications?

Thanks Paps.

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Willy Denoyette [MVP] (VIP)
Inline ***

Willy.

"Paps" <Click here to reveal e-mail address> wrote in message news:#mXdENn1BHA.2292@tkmsftngp07...
[Original message clipped]

Don't know for sure, but you should check whether the client has the rights to create queues and/or queued objects in the AD.

[Original message clipped]

No when running XP, the MSMQ service can access Queue objects registered in the AD, but that doesn't mean the MSMQ service should
run on the DC.
However when the client runs W2K a the DC must host a MSMQ server.

[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Jatin Zalavadia
In the Example of .NET http://localhost/quickstart/howto/doc/mqsend.aspx,
the source code looks like...
----------------------------------------------
using System;
using System.Messaging;

public class MQSend
{
public static void Main(String[] args)
{
string appName = Environment.GetCommandLineArgs()[0];

if(args.Length != 2) {
Console.WriteLine("Usage: " + appName +" <queue> <message>");
} else {
string mqPath = ".\\" + args[0];
if(!MessageQueue.Exists(mqPath)) {
MessageQueue.Create(mqPath);
}

MessageQueue mq = new MessageQueue(mqPath);
mq.Send(args[1]);
}

Console.WriteLine();
Console.WriteLine("Press Enter to continue...");
Console.ReadLine();
}
}
------------------------------------------
In the code, it checks for if the queue exists, if the queue does not
exist, Queue is created before opening queue and sending messages. The
above code should create queue if it does not exist. Do you have any
problem running the MQSend Sample?

From your first post the code you are using is,

MessageQueue MQ = new MessageQueue(".\\MyQueue");
MQ.Send(this, "Hello World");

If I have not missed any thing in the thread, this works if the queue is
manually created. If this is correct, do you check if the queue exists and
create if does not exist before opening the queue and sending message?

Queue consturctor MessageQueue MQ = new MessageQueue(".\\MyQueue") will
not create queue and send will error out if the Queue does not exist.

Jatin Zalavadia
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Rad
You say that other code works fine.. are you using the same code?

"Paps" <Click here to reveal e-mail address> wrote in message
news:#nhm8Hl1BHA.1228@tkmsftngp04...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Paps
"Rad" <Click here to reveal e-mail address> wrote in message
news:g0Fo8.30853$Click here to reveal e-mail address...
[Original message clipped]

No the other use MSMQ for queuing components:
Queued Components is a COM+ feature built on top of Message Queueing
Services (MSMQ) that provides a mechanism for invoking and executing
components asynchronously. When a client makes a call to a queued object,
the call is actually made to a recorder, which packages it as a message and
places that message in a queue. A listener reads the message from the queue
and passes it to the player. The player makes the actual method calls on the
server object.

And I think it's more complex then sending a simple string message.

Paps

Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Console
System.Environment
System.Messaging.MessageQueue
System.Messaging.MessageQueueException






Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Copyright © AMX Software Ltd 2008-2012. Portions copyright © Matthew Baxter-Reynolds 2001-2012. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734

Hi! 10 years ago I founded .NET 247. I am working on a new and exciting replacement for the site. Please join me on Twitter to discuss.

Thanks,
Matthew Baxter-Reynolds (@mbrit)

Follow mbrit on Twitter