There are lots of examples how to install windows service in one line:
ManagedInstallClass.InstallHelper(
new[] { Assembly.GetExecutingAssembly().Location });
That works fine until service class is declared in exe module.
But the same code doesn’t work for me if service class is in referrenced assembly (not declared in executable, but in linked dll).
In such a case service is registered as well but can’t be started as it is registered with dll path and points to dll (“service is not a win32 executable” message appears in event log when I try to start that)
If I change GetExecutingAssembly().Location to executable path, then no installers are found and service is not registered at all.
Is it possible to put service class into referenced assembly and still have ability to register service with minimum effort?
Thank you in advance!
here is some C# code that allows you to install/uninstall a service” manually” (without the need to declare custom RunInstaller attributes):