Andreas
Andreas

Reputation: 5631

Wix Setup Project for Windows Service causes FileNotFoundException

I have created a Wix Setup Project for a Windows Service. On my local developer machine (Windows 7 - 64) it runs and starts without problems. However when I try to install it on a Windows Server 2008 I get the "common" error of "Verify you have sufficient priviliges...". In the Event Viewer I can see that this is caused by the .NET Runtime throws a FileNotFoundException

Application: RT.Tools.AutoBettingWinService.exe

Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception.

Exception Info: System.IO.FileNotFoundException

Stack: at RT.Tools.AutoBettingWinService.Program.Main()

I've tried added all the files I could think of in my .wxs-file. It is as following

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="AutoBettingWinService.Setup" Language="1033" Version="1.0.0.0" Manufacturer="Norsk RT" UpgradeCode="5756e8b0-3eef-4b1c-9c74-60c05386bff5">

        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />

        <Feature Id="ProductFeature" Title="AutoBettingWinService.Setup" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="AutoBettingWinService.Setup" >
        </Directory>
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="RT.Tools.AutoBettingWinService" Guid="{8B3B5B09-701E-4BA4-9FD2-093072B303D3}">
        <File Id="Common.Logging.dll" Name="Common.Logging.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\Common.Logging.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="RT.Tools.Betting.dll" Name="RT.Tools.Betting.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.Tools.Betting.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="Moq.dll" Name="Moq.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\Moq.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\Newtonsoft.Json.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="nunit.framework.dll" Name="nunit.framework.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\nunit.framework.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="Quartz.dll" Name="Quartz.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\Quartz.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="RT.Testing.dll" Name="RT.Testing.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.Testing.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="RT.WebAPI.dll" Name="RT.WebAPI.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.WebAPI.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="System.Net.Http.dll" Name="System.Net.Http.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\System.Net.Http.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="System.Net.Http.Formatting.dll" Name="System.Net.Http.Formatting.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\System.Net.Http.Formatting.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="System.Net.Http.WebRequest.dll" Name="System.Net.Http.WebRequest.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\System.Net.Http.WebRequest.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="System.Web.Http.dll" Name="System.Web.Http.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\System.Web.Http.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="System.Web.Http.WebHost.dll" Name="System.Web.Http.WebHost.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\System.Web.Http.WebHost.dll" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="Thinktecture.IdentityModel.dll" Name="Thinktecture.IdentityModel.dll" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\Thinktecture.IdentityModel.dll" Vital="yes" KeyPath="no" DiskId="1"/>

        <File Id="_1000UserIds.txt" Name="1000UserIds.txt" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\1000UserIds.txt" Vital="yes" KeyPath="no" DiskId="1"/>

        <File Id="RT.Tools.AutoBettingWinService.exe.manifest" Name="RT.Tools.AutoBettingWinService.exe.manifest" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.Tools.AutoBettingWinService.exe.manifest" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="RT.Tools.AutoBettingWinService.exe.config" Name="RT.Tools.AutoBettingWinService.exe.config" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.Tools.AutoBettingWinService.exe.config" Vital="yes" KeyPath="no" DiskId="1"/>

        <File Id="RT.Tools.AutoBettingWinService.pdb" Name="RT.Tools.AutoBettingWinService.pdb" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.Tools.AutoBettingWinService.pdb" Vital="yes" KeyPath="no" DiskId="1"/>
        <File Id="RT.Tools.AutoBettingWinService.exe" Name="RT.Tools.AutoBettingWinService.exe" Source="..\RT.Tools.AutoBettingWinService\bin\Debug\RT.Tools.AutoBettingWinService.exe" Vital="yes" KeyPath="yes" DiskId="1"/>
        <ServiceInstall
              Id="ServiceInstaller"
              Type="ownProcess"
              Vital="yes"
              Name="AutoBettingService"
              DisplayName="AutoBettingService"
              Description="Places bets automatically a given time of day"
              Start="auto"
              Account="NT AUTHORITY\NETWORK SERVICE"
              ErrorControl="normal"
              Interactive="no"
              >
        </ServiceInstall>
        <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="AutoBettingService" Wait="yes" />
      </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

I've also tried to omit the 'Start' property and tried to start it manually, with the same result.

Can anyone tell me what's wrong with my setup? And why the FileNotFoundException?

Thanks!

Upvotes: 2

Views: 1294

Answers (2)

David Martin
David Martin

Reputation: 12248

Adding to what @Christopher Painter has said, I am going to assume that the problem is not with the install but rather what is not being installed, you have already alluded to not being sure what is dependencies your service has, so you should start diagnosing what dependencies your application requires.

Install the application but do not start the service, then start the service manually and by using Assembly Binding Log Viewer this will allow you to view binding failures at runtime, you may have to set HKLM\Software\Microsoft\Fusion\ForceLog to 1 to get all failures (see link for more details).

Upvotes: 2

Christopher Painter
Christopher Painter

Reputation: 55620

You'll need to profile the service to find out what is referred to by the FileNotFound exception and add it to the installer. Also, Windows Installer Component rules dictate that every one of your DLL files needs to be the keyfile of it's own component.

Upvotes: 1

Related Questions