Search code examples
c#wixwindows-installerlaunching-application

wix c# app doesn't launch after installing


I have already successfully generated and successfully installed my C # WPF application with Wix. The application includes Crystal report dll and some other dll like Zen Barecode. After an nth attempt to modify the main project, the MSI is able to install itself but by launching the application either from the shortcuts or the executable directly, it does not start.

Here is my wix product.wxs

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*"
           Name="MyApp 1.0.0"
           Language="1036"
           Codepage="1252"
           Version="1.0.0"
           Manufacturer="My Company"
           UpgradeCode="PUT-GUID-HERE">
    <Package InstallerVersion="200"
             Compressed="yes"
             InstallScope="perMachine"
             Description="Some description"
             Keywords="Some keywords"
             Comments="(c) some comments"
             />

    <MajorUpgrade DowngradeErrorMessage="La dernière version de MyApp est déjà installée" />
    <MediaTemplate EmbedCab="yes" />

    <Icon Id="icon.ico" SourceFile="$(var.InstallFolderPath)\logo.ico"/>

    <Feature Id="ProductFeature" Title="TPI SOFT" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentGroupRef Id="LibrariesComponents" />
      <ComponentGroupRef Id="CustomFonts" />
      <ComponentRef Id="CMP_MenuShortcut" />
      <ComponentRef Id="CMP_DesktopShortcut" />
    </Feature>

    <Property Id="ARPPRODUCTICON"
              Value="icon.ico" />

    <Property Id="ARPCONTACT"
              Value="My Contact"/>

    <PropertyRef Id="NETFRAMEWORK45"/>
    <Condition Message="Ce logiciel requiert l'installation préalable de Microsoft .NET Framework 4.5 ou plus.">
      <![CDATA[Installed OR NETFRAMEWORK45]]>
    </Condition>

    <Condition Message="Ce logiciel tourne sur tous les systèmes Windows à partir de Windows Vista">
      <![CDATA[Installed OR VersionNT >= 600]]>
    </Condition>

    <Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
    <UIRef Id="WixUI_InstallDir" />

    <WixVariable Id="WixUILicenseRtf"
                 Value="$(var.InstallFolderPath)\licence.rtf" />

    <WixVariable Id="WixUIDialogBmp"
                 Value="$(var.InstallFolderPath)\dialog_bmp.bmp"/>

    <WixVariable Id="WixUIBannerBmp"
                 Value="$(var.InstallFolderPath)\top_banner.bmp"/>

    <Property Id="ApplicationFolderName"
              Value="MyApp\MyApp" />

    <Property Id="WixAppFolder"
              Value="WixPerMachineFolder" />

  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="COMPANYFOLDER" Name="My Company">
          <Directory Id="APPLICATIONFOLDER" Name="My App 1.0.0">
          </Directory>
        </Directory>
      </Directory>

      <Directory Id="ProgramMenuFolder">
        <Directory Id="MyStartMenuShortcutDir"
                   Name="My App"/>
      </Directory>

      <Directory Id="DesktopFolder">

      </Directory>

      <Directory Id="FontsFolder">

      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
      <Component Id="cmp436C9F728138518252041AF1E09808A9" Guid="PUT-GUID-HERE">
        <File Id="filC9EEE3E54616B953432FF36EDA3020A3" KeyPath="yes" Source="$(var.MyApp.TargetDir)MyApp.exe" />
      </Component>
      <Component Id="cmp840D318334E734AB5C8FA4C807C4CB95" Guid="PUT-GUID-HERE">
        <File Id="filE698BF079DEBA8E2BC7F2E69833E372D" KeyPath="yes" Hidden="yes" Source="$(var.MyApp.TargetDir)MyApp.exe.config" />
      </Component>

      <Component Id="CMP_Licence"
                 Guid="558784B2-E92A-4686-95BD-A034E859E8A7">
        <File Id="licence"
              Source="$(var.InstallFolderPath)\licence.rtf"
              KeyPath="yes" />
      </Component>
    </ComponentGroup>

    <ComponentGroup Id="CustomFonts" Directory="FontsFolder">
      <Component Id="CMP_DigitalFont"
                 Guid="PUT-GUID-HERE">
          <File Id="digitalFont"
                Source="$(var.FontFolderPath)\digital-7.ttf"
                TrueType="yes"
                KeyPath="yes" />
      </Component>
    </ComponentGroup>

    <Component Id="CMP_MenuShortcut"
               Directory="MyStartMenuShortcutDir"
               Guid="PUT-GUID-HERE">

      <Shortcut Id="MenuShortcut"
                Name="MyApp 1.0.0"
                Description="Lance le logiciel MyApp"
                Target="[APPLICATIONFOLDER]MyApp.exe"
                WorkingDirectory="APPLICATIONFOLDER"
                Icon="icon.ico"/>

      <RemoveFolder Id="RemoveMyStartMenuShortcutDir"
                    On="uninstall" />
      <RegistryValue Root="HKCU"
                    Key="Software\MyApp"
                    Name="installed"
                    Type="integer"
                    Value="2"
                    KeyPath="yes" />
    </Component>

    <Component Id="CMP_DesktopShortcut"
               Directory="DesktopFolder"
               Guid="PUT-GUID-HERE">
      <Shortcut Id="DesktopShortcut"
                Name="MyApp 1.0.0"
                Description="Lance le logiciel MyApp"
                Target="[APPLICATIONFOLDER]MyApp.exe"
                WorkingDirectory="APPLICATIONFOLDER"
                Icon="icon.ico"/>
      <RemoveFolder Id="DesktopFolder" On="uninstall"/>
      <RegistryValue
                 Root="HKCU"
                 Key="Software\MyApp"
                 Name="installed"
                 Type="integer"
                 Value="1"
                 KeyPath="yes"/>
    </Component>

  </Fragment>
</Wix>

Solution

  • UPDATE: The issue was a missing application parameter in an outdated config file. A configuration issue in other words. Found by attaching debugger to the launching app. See below.


    Logging: Do you see any clues in the event viewer or whatever other logging constructs your application provides? Maybe you can enable debug logging for the application via its configuration files or registry settings?

    Launch Problems Check-List: I wrote a general-purpose check-list for application launch problems at one point. Maybe have a look and see if something rings a bell.

    Debug Binaries - Launch Sequence Debugging: You could insert a message box early in your application launch sequence and slipstream the debug binaries into your setup, install it, and then attach the debugger to the application's message box on launch in order to step through the launch code? (set a breakpoint).

    • Maybe check this nice Advanced Installer Video Tutorial for this "attach debugger approach". It shows the same approach for custom action code. The procedure is the same for launching applications. Just attach to message box and set breakpoints.

    • Note: Obviously remember to recompile with the release binaries once you know what the problem is - and retest launching. Debug binaries are not redistributable - they bind to debug dlls only installed by the MS SDK. Normal PCs will not (normally) have these debug dlls (making this procedure primarily about configuration problems and not about runtime dependency issues).

    Updated disclaimer:

    Disclaimer: Though obvious, it has to be mentioned: never use debug binaries for actual release. 1) Not at all legal, 2) not a good idea due to the transparency and reverse-engineering possibilities of debug binaries (win32 binaries), and 3) debug runtime binaries will not exist on non-developer boxes. And finally: it could be easy to forget to rebuild with release binaries when you mess around with debugging like this. It sure happens (though different file names should help distinguish debug-binaries).


    Similar Answers: Rather than repeating myself here, I will link to a few similar answers from earlier. Please skim this to see if you see anything that rings a bell: