When installing a Generic Host as a service in NServiceBus, how do I provide valid credentials?
nservicebus, topshelf
Solution
(2.) can I configure credentials as command line arguments to NServiceBus.Host.exe or run as 'Local System Account'?
After digging around in TopShelf and NSB source code I discovered that this is pretty simple:
For anyone who's interested - this is something the TopShelf implements with IRunnerConfigurator.RunAsLocalSystem. NServiceBus calls this method if you add the marker interface ISpecify.ToRunAsLocalSystem
So the answer is to add ISpecify.ToRunAsLocalSystem to the list of interfaces implemented by the EndpointConfig class.
I didn't find an answer to:
(1.) what credentials can I pass to get this to work?
But now I don't really need one now as I'm happy enough to run the services as Local System.
Problem
Imagine I create a .bat file in the following directory: \trunk\Samples\PubSub\ ``` @ECHO OFF ECHO installing Subscriber 1 Subscriber1\bin\Debug\NServiceBus.Host.exe /install pause ECHO installing Subscriber 2 Subscriber2\bin\Debug\NServiceBus.Host.exe /install pause ECHO starting Subscriber services net start Subscriber1.EndPointConfig_v1.0.0.0 net start Subscriber2.EndPointConfig_v1.0.0.0 pause ``` I get prompted for a username and password, but using my own credentials I get an exception as follows: An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The account name is invalid or does not ex ist, or the password is invalid for the account name specified what credentials can I pass to get this to work? can I configure credentials as command line arguments to NServiceBus.Host.exe or run as 'Local System Account'? Note: My research so far suggests that (2) may be something that TopShelf supports via it's IInstallationConfiguration I'm doing this on a Vista machine with MSMQ installed already. The PubSub sample runs as expected if I just run the subscriber instances as console apps (i.e. like this): ``` @ECHO OFF ECHO starting Subscriber 1 Subscriber1\bin\Debug\NServiceBus.Host.exe NServiceBus.Integration pause ```