Pregunta

I have a project that includes an ATL service. Currently, our installer registers the service with custom actions that run the installed service executable with the command:

MyService.exe /server

and unregisters it with the command

MyService.exe /unregservice

This has caused headaches in some situations where the command has failed and the installation becomes stuck in a state where it can neither be completed or fully rolled back, leaving the application unusable.

We would like to replace these custom actions by using the ServiceInstall tag to do the registration completely within the MSI file, but we can't get it to work. Our initial code looked like this:

<Component Id="c.MyService.exe" Guid="{PUT-GUID-HERE}">
    <File Id="f.MyService.exe" Name="MyService.exe" KeyPath="yes"
          DiskId="1" Source="$(var.MyService.TargetPath)" Vital="yes" />

    <ServiceInstall Id="svci.MyService" Name="MyService" Type="ownProcess"
                    Start="demand" ErrorControl="normal" DisplayName="MyService"
                    Description="My Service" Account="LocalSystem" Interactive="no"
                    Vital="yes">
      <ServiceDependency Id="RPCSS"/>
    </ServiceInstall> 
    <ServiceControl Id="svcc.MyService" Stop="both" Remove="uninstall" 
                                     Name="MyService" Wait="yes" />

</Component>

The install would complete, but running the program failed with this message:

Retrieving the COM class factory for component with CLSID {...} failed due to the following error: 80040152 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

One suggestion found via google was to add in the AppId tag inside the Component tag as follows:

<Component ... />
...
<AppId Id="$(var.MyServiceGUID)" LocalService="MyService" Description="MyService" /> 
...
</Component>

However this didn't have any effect.

Any ideas how to replicate the ATL's self-registration in the MSI itself?

For reference, I believe I am having the same problem as in this ancient, unanswered post: http://social.msdn.microsoft.com/Forums/vstudio/en-US/eb33cf47-628a-4fbf-a740-f81afe2f2b43/atl-service-install-and-registration-issue-com-server-vs-windows-service?forum=vcgeneral

Thanks very much

¿Fue útil?

Solución

WiX has a program called Heat that can be used to harvest the COM metadata for your ATL server. Run this program to generate a wxs fragement, migrate the COM elements to your wxs fragement then rebuild and test on a clean snapshotted VM. Rinse and repeat if needed as COM/ATL is a little tricky at times.

Harvest Tool (Heat)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top