I am trying to create a service that can be installed multiple times (different "instances"). So - first I figured out how to get to the serviceInstaller.Context.P
arameters which let's me pass the service name in on the command line. When installing the service, I can attach to the BeforeInstall event and rename the serviceInstaller.ServiceNa
me property to reflect the instance name passed into the InstallUtil.exe on the command line - works GREAT.
Now - here's my question - for some BIZAR reason that I can NOT figure out - when I try to do the reverse (attaching to the BeforeUninstall event) so that I can uninstall the specific service instance that was previously installed, the InstallUtil.exe seems to behave in a completely unexpected way. Specifically - it tries to uninstall the service with the default service name assigned at design time (which of course fails because the service was renamed on install) BEFORE firing my BeforeUninstall event handler?? WTF?
I'm totally confused - shouldn't the BeforeUninstall event run BEFORE IT TRIES TO UNINSTALL THE SERVICE? I added a windows message box to that event handler, and when I run:
InstallUtil /u MyService.exe
I can see it try (and fail) to uninstall the service and THEN my message box pops up? What am I missing here?