Msmq and WCF Service

北城以北 提交于 2019-12-22 04:39:09

问题


I have created a WCF service using the NetMsmq binding for which i created a private queue on my machine and executed the project. This works fine as such and my WCF service is started and accesses the message using the queue in the debugging environment. Now, I wanted to host the service using the windows service and for the same I created a new project and windows installer as well (This service runs under Local System Account). Then I tried installing this windows service using the InstallUtil command through the command prompt. When installation is happening and during the service host opening, I get an exception saying:

There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information. 
Inner Exception System.ServiceModel.MsmqException: An error occurred while opening the queue:Access is denied. (-1072824283, 0xc00e0025). The  message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that the queue is available to open with the required access mode and authorization.
   at System.ServiceModel.Channels.MsmqQueue.OpenQueue()
   at System.ServiceModel.Channels.MsmqQueue.GetHandle()
   at System.ServiceModel.Channels.MsmqQueue.SupportsAccessMode(String formatName, Int32 accessType, MsmqException& msmqException)

Could anyone suggest the possible solution for the above issue? Am I missing any permissions to be set for the queue as well as the windows service, if so could you suggest where should these permissions be added?


回答1:


Tom Hollander had a great three-part blog series on using MSMQ from WCF - well worth checking out!

  • MSMQ, WCF and IIS: Getting them to play nice (Part 1)
  • MSMQ, WCF and IIS: Getting them to play nice (Part 2)
  • MSMQ, WCF and IIS: Getting them to play nice (Part 3)

Maybe you'll find the solution to your problem mentioned somewhere!




回答2:


Yes, it looks like a permissions issue.

Right click on your private queue from the Server Manager, and select Properties. Proceed to the Security tab, and make sure you have the right permissions in there for your Local System Account.

This is also confirmed in Nicholas Allen's article: Diagnosing Common Queue Errors, where the author defines the error code 0xC00E0025 as a permissions problem.




回答3:


I ran into same problem, here is the solution.

Right click "My Computer" --> Manage. In Computer Management window go to "Services and Applications --> Message Queueing --> ur queue", select ur queue and access properties. Add the user running ur WCF application and give full access. This should solve the issue.




回答4:


Can simple be that the service can't find the it's queue. The queue name must exact match the endpoint address.

Example:

net.msmq://localhost/private/wf.listener_srv/service.svc

points to local queue

private$\wf.listener_srv\service.svc

If queue name and endpoint are according to each other, then is most like that the credentials defined on the IIS pool don't grant access to the queue.



来源:https://stackoverflow.com/questions/2154853/msmq-and-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!