cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Ron_Schaeffer
Level 6

Starting Services and GAC issues?

We have an installer which delivers a number of files, including a service executable. The current installer delivers all the files to a target disk folder and everything works fine, including the service creation and start by the installer.

However, now the developers desire to put some assemblies into GAC; so I have changed the target destination for those assemblies to the GlobalAssemblyCache - and now the installer start of the service fails with "Error 1920. Service failed to start. Verify that you have sufficient privileges to start system services."

I have found hints elsewhere that having the installer start a service dependent on GAC assemblies installed by the same installer may be a problem - can anyone give me a full story (and hopefully an easy solution 🙂 )? Do I have to abandon using the builtin installer service startup, and /or write my own service startup?
Labels (1)
0 Kudos
(7) Replies
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The MSI ServiceControl table doc provides more information regarding this issue:
Note Services that rely on the presence of an assembly in the Global Assembly Cache (GAC) cannot be installed or started using the ServiceInstall and ServiceControl tables. If you need to start a service that depends on an assembly in the GAC, you must use a custom action sequenced after the InstallFinalize action or a commit custom action. For information about installing assemblies to the GAC see Installation of Assemblies to the Global Assembly Cache.


You could try using an InstallScript custom action and the ServiceAddServce and ServiceStartService functions as an alternate method for installing and starting a service with GAC dependencies.
0 Kudos
Ron_Schaeffer
Level 6

Thanks Josh.

It seems to be an obvious question as to why the current actions simply aren't resequenced in the InstallExecute sequence, so I must be missing something?

The InstallServices action seems to work where it is, although the StartServices does fail. Is it possible to force the StartServices action to after InstallFinalize? If not, then can we leave the InstallServices to do its thing and only use a custom action after InstallFinalize as was suggested?

The StopServices and DeleteServices actions would seem to simply need to be executed earlier in the sequence, before the assemblies get unpublished?

Sorry if the answers are obvious, but I'm not seeing them.
0 Kudos
Ron_Schaeffer
Level 6

I did a trial, whereby I changed the InstallExecuteSequence such that Stop Services / Delete Services were moved earlier in the sequence (after AllocateRegistrySpace), and I turned off the 'start service on install'. This seems to work - albeit with only limited trials.

Now, has anyone out there developed their own StartService type custom action (at the moment I have a Basic MSI with a few VBScript custom actions - I'm trying to avoid having to drag in InstallScript, which involves yet another prerequisite)?

----------------------------------

Not that I want to discuss it here, but for anyone else looking at the GAC, there appears to be major issues with installations involving the GAC - see this conversation: http://community.flexerasoftware.com/showthread.php?t=187362&highlight=gac. And, no, I haven't dealt with these issues yet.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Sequencing of the StartServices action is documented here. InstallShield sequences this action similar to the documented requirements. Attempting to move the action could result in unpredictable behavior.

Note that the InstallScript engine has been self-contained since IS 12 and no longer requires any resources be installed on a target machine. However, if there is another method you would prefer to use as a custom action (EXE, DLL, VBScript, etc.) to control services, any of them should work fine as long as they are sequenced after InstallFinalize (or as a commit custom action).
0 Kudos
Ron_Schaeffer
Level 6

I wasn't thinking of resequencing the InstallShield provided / built-in StartServices action - from what I have seen in the logs it almost appears to function as a Deferred (or delayed?) action, hence my reluctance to even try resequencing it.

The documentation link indicates the relative sequence of services related actions, but doesn't provide any caveats regarding resequencing. In theory I could move StartServices after InstallFinalize and not be in contravention of the documentation.

Re InstallScript [guess that shows how long I have dabbled with this stuff 🙂 ] - I'll take another look at your prior documented suggestion [If you need to start a service that depends on an assembly in the GAC, you must use a custom action sequenced after the InstallFinalize action or a commit custom action.] regarding an InstallScript custom action employing ServiceStartService function.

Thanks Josh.
0 Kudos
Ron_Schaeffer
Level 6

I've developed a simple CA which calls ServiceStartService InstallScript function - but it seems to always be returning -1 (even though the service is started). Has anyone encountered this before (and resolved it)?

FYI - this was happening in my trial GAC installer, so I went back to my original (non-GAC) installer, turned off the 'start on install' option in the service control, and then implemented my CA after InstallFinalize. Even in this case, the the service is started but ServiceStartService returns -1.
0 Kudos
SMadden
Level 6

I don't know about the specific InstallScript calls you use, but we also install a service that depends on assemblies in the GAC.

I used an exe custom action that calls "net start ". The working directory is SystemFolder and it's scheduled in the Execute sequence right after MsiPublishAssemblies.

Because it needs elevated rights on Vista/Win7 to be able to start the service, but also needs to happen after InstallFinalize so that the GAC assemblies are published, I used a Commit CA that runs in System Context.

I know that if rollback is disabled, this CA will not be run, but it was the best I could come up with that otherwise works fine on all systems.

Having an Immediate CA after InstallFinalize only worked on XP, but not on Vista/Win7.

Sandra
0 Kudos