gzak
gzak

Reputation: 4110

MSMQ read error (access denied)

I create a queue on my local machine in some other process as follows:

MessageQueue.Create(@".\private$\sampleQueue");

And in my reader process, I attach to it as follows:

var queue = new MessageQueue(@".\private$\sampleQueue");

When I try to do queue.Peek(), I get an access denied exception. I'm not on a domain, this is just my local workgroup computer. Any ideas?

Upvotes: 1

Views: 1328

Answers (3)

Russell McClure
Russell McClure

Reputation: 4851

The credentials used by the process that creates the queue must be different from the credentials of the process used to read the queue. If that is the way it must be, then you will need to specifically grant the needed read permissions on the queue after you create it.

Upvotes: 2

John Breakwell
John Breakwell

Reputation: 4687

MSMQ uses different protocols for it's work:

  • Pushing information (sending messages) uses MSMQ protocol.
  • Pulling information (receiving messages, getting properties, etc) using RPC protocol.

If it is not a simple permissions issue (which it is very likely to be) then you need this blog post:

Understanding how MSMQ security blocks RPC traffic http://blogs.msdn.com/b/johnbreakwell/archive/2010/03/24/understanding-how-msmq-security-blocks-rpc-traffic.aspx

Cheers
John

Upvotes: 3

Dave Ziegler
Dave Ziegler

Reputation: 1745

If you r-click on the queue in Computer Management and select properties, do you have the appropriate permissions set on the Security tab?

Upvotes: 2

Related Questions