mbearden
Posts: 8
Joined: Tue Jan 30, 2007 11:20 pm
Location: Atlanta, GA

Service will not start; GAC assemblies not yet installed

I have a service that won't start when the installer tries to start it, because
the installer has at that time not yet unpacked and copied to the
destination media all the files that the service depends on to run. I have
narrowed it down to a particular type of file that has not been unpacked
before services are started.

Here are details, generalized a bit. I'm using AI v. 4.9.2.

I have a service with executable file A that depends on DLL file B.
My installer files include both A and B files.

File B is a .NET assembly. I have created an entry under Project Details /
Assemblies in the installer definition that says to registered file B with the
Global Assembly Cache (GAC).

I defined a service in the installer based on A, and told the installer to
start the service by defining under Services a control operation with Start
checked.

When I try an installation, service A fails to start when the installer tries to
start it. By careful inspection, I have discovered this is the sequence of
actions taken by the installer:

1. Unpack file A and all other files *except for* any file that is an
assembly set to be registered with the GAC.
2. Try to start service based on A
3. Unpack file B along with any other files to be registered with GAC
(presumably...actually I have never yet made it to this stage, but
if I tell the installer not to start the service (no step 2), then
I eventually do make it here.)

The dependent DLL file B wasn't unpacked (nor were several other files
that I specified to be registered in the gAC) when the installer tried to start
my service A.

So is this an AI bug, or a deficiency in the MSI engine? Is there any
workaround, I am wondering?

---

UPDATE: I tried getting my file B regsitered in the GAC by *Not* creating
an entry for it under Project Details / Assemblies, but instead by checking
the Registration (register .NET assembly for COM) option under Properties
for B's entry under Project Definition / Files and Folders.

I see the following changed behavior: At the time the installer tries to
start service A, this time file B *has* been unpacked from the installer,
BUT it has not yet at this point in time been registered with the GAC. So
my service still fails to start...
Last edited by mbearden on Thu May 17, 2007 8:25 pm, edited 2 times in total.
mbearden
Posts: 8
Joined: Tue Jan 30, 2007 11:20 pm
Location: Atlanta, GA

OK, this appears to be a weakness in Windows Installer and/or a "bug" in
Advanced Installer. ("Bug" here meaning that AI doesn't automatically
generate a workaround for the documented weakness in MSI.)

Apparently Advanced Installer is not generating MSI files that will start a
service in a way that works in all cases...specifically in the case where a
service depends on an assembly in the GAC that is also being installed by
the installer.

Here is the Microsoft source that documents the apparent cause of my
problem:

http://msdn2.microsoft.com/en-us/library/aa371634.aspx

It says: "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."

This is apparently a common problem. Here are other people having the
similar problem, not using Advanced Installer.

http://www.dotnet247.com/247reference/m ... 85193.aspx
http://www.microsoft.com/communities/ne ... ttings.xml

I either need Advanced Installer to transparently transform each start
service request into a custom action for me, or else I must manually do
this myself when defining my Advanced Installer project.
mbearden
Posts: 8
Joined: Tue Jan 30, 2007 11:20 pm
Location: Atlanta, GA

More details documented here as I work toward a solution for my
own project...

MSI runs actions in the following order. These actions can be exposed in
Advanced Installer by going to Custom Actions definition pane and right
clicking, then selecting from the context menu "Show Standard Action".

...
InstallServices
StartServices
...
Install
Commit
...
MisPublishAssemblies
...
InstallFinalize

It's apparently the MsiPublishAssemblies action that registers installed
assemblies with the GAC. See this Microsoft site:
http://msdn2.microsoft.com/en-us/library/aa370359.aspx

Therefore, a custom action added to Commit to start one of these
GAC-dependent services will also not work. The custom action step needs
to go, apparently, into the InstallFinalize action.
kkim
Posts: 44
Joined: Thu Apr 12, 2007 3:58 pm

Are you actually getting an error that says "GAC assemblies not yet installed"

Or is that just an addition to your subject line?

Also, are you getting an error 1920 in your event log?

Return to “Common Problems”