开发者

Win Service getting permission denied to Message Queuing

I have a WinService that can't start because NServiceBus throws "Service cannot be started. System.Messaging.MessageQueueException (0x80004005): Access to Message Queuing system is denied."

This is on Windows 7

I have tried to run the service as: LocalSystem, Localservice, and NetworkService

here is how I'm setting up NServiceBus

 pr开发者_开发技巧ivate static IBus _serviceBus;
    private static AuditMessageHandler _messageHandler;

    public AuditQueueProcessor()
    {
        _messageHandler = new AuditMessageHandler();
        _serviceBus = Configure.With()
            .Log4Net()
            .DefaultBuilder()
            .XmlSerializer()
            .MsmqTransport()
            .IsTransactional(true)
            .PurgeOnStartup(false)
            .UnicastBus()
            .ImpersonateSender(false)
            .LoadMessageHandlers()
            .CreateBus()
            .Start();
    }

here is my Config

<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>

  </configSections>

  <MsmqTransportConfig InputQueue="LoggerInputQueue" ErrorQueue="LoggerInputError" NumberOfWorkerThreads="1" MaxRetries="5"/>

  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="Truckstop2.Imports.Objects.AuditMessage,Truckstop2.Imports.Objects" Endpoint="InputQueue@newimp001" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>


Found the solution !

It's because service incorporated in NETWORK SERVICE user. You need to set permisions to the private MSMQ your accessing to do this

  1. open Computer Management
  2. Expand Message Queuing
  3. Expand Private Queues
  4. right click on the Queue your using and select Properties
  5. select the security tab and set permissions to your local user
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜