views:

96

answers:

2

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

 private 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>
+1  A: 

Have you tried to run the service as a user with local admin privileges, with windows 7 this may be a case of AUC blocking your access

Trucker Bob
I have AUC turned down but I'll give that a try
Bob The Janitor
+1  A: 

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
Bob The Janitor