Access denied for Windows Service MQ

Source: Internet
Author: User
Tags msmq
Set two applications Program Application A is a Web application, and application B is a Windows service.
Application A generates MSMQ named C (references C if it exists) and inserts records into C.
Application B generates MSMQ named C (references C if it exists) and reads records from C.
The two applications and message queues are on the same server.

The following symptoms occur when two applications are started:
If C does not exist.
It is normal when application a starts and application B starts again.
When application B starts and application a starts again, application a cannot read c. Access denied error. Moreover, the administrator cannot manually delete C.

View the Security Information of C under normal conditions and errors. Different creators are found. This error is caused by the permission.

Add the following when creating or referencing MQ:Code(Red part ).
Messagequeue MQ = NULL;
If (messagequeue. exists (@ ". \ private $ \" + mqname) = false)
{
MQ = messagequeue. Create (@ ". \ private $ \" + mqname, true );
MQ. setpermissions ("Everyone ", messagequeueaccessrights. fullcontrol);
}
Else
{
MQ = new messagequeue (@ ". \ private $ \" + mqname );
}
MQ. formatter = new binarymessageformatter ();

The red part means that when the application is an Asp.net application (Web Application)-then the user is ASPnet, and the message queue established by the system by default is fully controlled by everyone. If you create a message queue for a Windows service or a winform application-if you are not using ASPnet as system or administrator, you must grant permissions to everyone to create a message queue.

The above is for Asp.net. Other web applications can also refer to this idea when competing with Windows applications for MSMQ.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.