I have a problem with a C# app using MSMQ. The problem has just started occurring in the last week or so. It is happening on both an existing PC and a newly installed PC, both are running XP Pro - the problem does not appear to occur in W2k3 server.

The setup is this;

I have a w2k3 server running a windows service which listens to several message queues for requests, and sends repsonses to clients. The two clients are XP pro and running a C# WinForms client. All of the PC's have MSMQ installed, but without active directory integration, and they're using private queue names (either direct=tcp:<address>\private$\blah or direct=osStick out tonguecname\private$\blah).

All of this has been working fine until this week. When I tried it this week, using a new PC, or the existing PC with a new queue name, I no longer received the responses from the server. The specific symptoms are;

1. Server receives the request, and my logging to the event log says a response was sent.

2. There is no message in queue on the sending PC (although the outgoing queue exists).

3. The message does not appear in the receiving queue on the client PC, and my client app never says it go the message.

4. If I send the request and ask the server to send the response to a non-existent IP, then the outgoing queue on the server (to the non-existent pc) gets created, and the message is shown waiting in the queue, so I am sure the server is sending it.

Note, this is very disturbing, since MSMQ seems to be just losing the message completely, and silently, which it isn't ever supposed to do

Anyway.. after much trial and error I have narrowed down the problem to the fact that the program is creating the queue for me. If I manually create the queue using the MSMQ snap-in, it works, if my software creates the queue for me, it doesn't (symptoms as above). Weirdly, I have completed the properties of both queue (using the property dialog in the MMC snap-in) for a self-created queue and an client-created queue, and the properties are all exactly the same, yet one works and the other doesn't.

My software has been creating it's own queues for months, without any problems, and now this - even on a clean install of XP (Sp2 - with all windows updates applied). I am kinda of suspecting a windows update or something has caused the problem.

Anyone got any other ideas, or know of a specific problem with a windows update etc


PS: While not exactly my actual code, here is a code sample to create the queue, which does cause the problem I'm talking about;

private MessageQueue CreateQueue(string path)


if (!MessageQueue.Exists(path))

MessageQueue.Create(path, false);

MessageQueue queue = new MessageQueue(path, QueueAccessMode.SendAndReceive);



queue.SetPermissions("Everyone", MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow);


catch (Exception e)


Globals.Log.WriteLine(this, EventSeverity.Error, String.Format("Error {0} setting queue permissions for 'Everyone' on queue; {1}.", e.ToString(), path));



return queue;

} //End of CreateQueue method.

private void SetQueueProperties(MessageQueue queue)


queue.Authenticate = false;

queue.EncryptionRequired = EncryptionRequired.None;

queue.Formatter = m_MessageFormatter;

queue.DefaultPropertiesToSend = m_DefaultSendProperties;

} //End of SetQueueProperties method.

Re: Visual C# General C#/MSMQ Issue

Jeremy Filburn

What is the message size you are trying to send back Maybe the size is your problem or maybe not. Just a thought.

MSMQ can support messages under 4 MB in size only!

Re: Visual C# General C#/MSMQ Issue


Thanks, for the response, but not my problem I'm afraid.

I'm aware of the 4mb message limit, and the messages I'm trying are of varying size but all well under 4mb (between 1k and 60k).

Re: Visual C# General C#/MSMQ Issue

Jeremy Filburn

I would check firewall settings and make sure that any AntiVirus / Internet Security programs are not running until you get it resolved if possible. DMZ the client if behind a router, and verify the following on the server side:

The following ports are used for Microsoft Message Queuing operations:

? TCP: 1801
? RPC: 135, 2101*, 2103*, 2105*
? UDP: 3527, 1801
The following is new for Message Queuing 3.0:

While Message Queuing uses the same ports that are used in earlier versions of the product, Message Queuing also introduces TCP port 389. TCP port 389 has to be open for MQIS queries that are made directly against Active Directory. Additionally, Message Queuing 3.0 introduces HTTP Messaging that requires that the port that is specified for the Message Queuing virtual directory be open also.

* These port numbers may be incremented by 11 if the initial choice of RPC port is being used when Message Queuing initializes. A connecting QM queries port 135 to discover the 2xxx ports.

Re: Visual C# General C#/MSMQ Issue


Thanks for the suggestions, but the only firewall installed is the windows one (on both server and clients) and I've turned that off completely. All anti-virus software has been removed from the server and old client, the new client PC has never had any installed.

I'm not using active directory integration, so presume port 389 is irrelevant (Although with no firewalls on it ought not be a problem anyway). Also, I haven't installed the HTTP component for MSMQ, so that's not in use and there is no virtual directory for MSMQ in IIS as a result.

Additionally, since the queues do work when I create them manually, that suggests to me that it's not a port issue - the ports work when the queue names are setup manually, so the ports must be open/working

At the moment we're working on a test system and all the PC's (server/client) are simply running on their own 100mb LAN - there are no routers involved and no DMZ in between. It's a really simple setup, which is one of the reasons this problem is so concerning. If I enable file sharing etc. it all works fine, and the PC's can ping each other and see each other in network neighbourhood etc. I've also tried putting the two clients in a workgroup (instead of the servers domain), and I get the same symptom - the queues work when the queues are created manually, but not when the C# code creates the queues for me.

Any other ideas

Re: Visual C# General C#/MSMQ Issue


Another piece of information (and this is very weird)...

We created a queue manually, and it worked fine. We then went into the security properties and removed the 'everyone' entry (which was added by default), added administrators/users etc. instead and it stopped working (same symptoms). So then we went back into the security properties, removed the users/administrator entries and put everyone back (with full control) - and it was still broken, even though this was the way it was configured initially.

Now that's weird in itself, but even if the security on the local queue didn't allow my app to read it etc. surely the messages should disappear from the sending queue and never arrive in the local queue The MMC snap-in hasn't been reporting any security errors, and neither has my app. We were logged on as a local admin anyway, so we should have always had permissions.

Anyone got any clues now

Re: Visual C# General C#/MSMQ Issue

Jeremy Filburn

Have you tried adding permissions for System

Re: Visual C# General C#/MSMQ Issue


I am now having this problem at a client site, and it is causing them grief, so I really need to get it sorted. I have tried deleting and re-creating the receiving queue manually (which fixed the problem in house on our demo gear) but this hasn't helped at the customers place. I've double checked all their IP's/queue names etc and they're fine, plus the end having problems receiving is able to send messages out ok.

I have added the local System account to the queue and given it full permission, then stopped and restarted the MSMQ service, but still the same symptoms. Regardless, with the queues that do work, System isn't applied in the security settings anyway, so I don't think it's a security issue (although I could be wrong).

The queues are non-transactional - can't remember if I mentioned that before, although, again, it shouldn't make any difference. I can't understand why it works with some queues on some computers, and not others, or why the sending PC removes the messages from the queue when they're clearly not arriving on the client.

Re: Visual C# General C#/MSMQ Issue


Ok, I'm still highly confused, but think it must be a problem with my sending code - although I'm not getting an error, it still works on some PCs/Queues, and I can't see anything wrong with the code.

I just found and read the MSMQ FAQ and buried two thirds of the way through it is my exact symptom. It says this is a common scenario (! !!!)

Anyway, to diagnose it, it recommends sending a message with the dead letter queue stuff enabled, journalling enabled, and a certain combination of receipt acknowledgements. I did this (in a test app, not my real app since I didn't want to have to change the software while the other clients are using it successfully) and guess what... the message arrived in the destination queue fine and the journal copy indicated everything was ok, and there was nothing in the dead letter queue.

Tried resending messages from my actual application, and still have the problem, even after restarting it.

The code I'm using is basically the same for both the actual app and the test app, except for the extra properties set for the diagnosis, so now I can't figure out why the test message works and the real ones don't. Arrgghh.


Thanks everyone.

Re: Visual C# General C#/MSMQ Issue


FYI... using my test program at the client site, with the dead letter queue, journalling and explicit receipt acknolwedgments turned off, the message fails to arrive, so it looks like one of those settings 'fixes' the problem - but I'm not sure why.

Any clues now anyone