1

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>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Can someone help me please? – Jonathan Mub Nice Sep 10 '18 at 19:14
  • Can you put break points into the c# code to see where it fails? Can you go back to a working version of Xml? – jdweng Sep 10 '18 at 19:18
  • I almost did not modify the Xml file. I made some changes on my c# code. When I launch the application from Visual Studio, all changes are taken into account correctly. I checked the log file with wilogutl.exe but I do not see anything. No error was returned by the installer – Jonathan Mub Nice Sep 10 '18 at 19:35
  • Can you put a break point (click on line of code then press F9) before the modified code and then see if it reaches the c# code? Then step through change to make sure they work. If break point can't be used add a Console.WriteLine("Test") then when message is displayed go to Visual Studio menu : debug : Break All. – jdweng Sep 10 '18 at 19:47
  • Though this appears to be an **application launch issue**, and **not a custom action code issue**, I suppose 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 to step through the launch code? Obviously remember to recompile with the release binaries once you know what the problem is. Debug binaries are not redistributable - they bind to debug dlls only installed by the MS SDK. Normal PCs will not have them. – Stein Åsmul Sep 10 '18 at 19:52

2 Answers2

0

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:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • I did not do any logging. By the way, I do not have too many experiences with Wix. The exe that is in Visual Studio's / bin / Debug folder runs fine, but the exe with Wix in Program files does not want to start even though I've had it with all the dlls and other dependency files. – Jonathan Mub Nice Sep 10 '18 at 19:57
  • Very common problem, I wouldn't worry too much. Please just investigate the check list above for ideas first, and then perhaps also the linked answer from earlier. And maybe consider the suggestion to install debug binaries that show a message box that you can attach to from Visual Studio to debug the launch sequence? – Stein Åsmul Sep 10 '18 at 19:59
  • I inlined the debug binary debugging suggestions in my answer above. – Stein Åsmul Sep 10 '18 at 20:15
  • Thank you very much for your prompt reactions. I added a message box at the launch sequence of the application. But I do not see how to attach the application from Visual Studio (or I did not understand your explanation very well). Can you tell me more about it, please? – Jonathan Mub Nice Sep 10 '18 at 20:29
  • Did you see the video above from Advanced Installer? If not, please check it out. It is very short, but very informative as well. – Stein Åsmul Sep 10 '18 at 20:30
  • After attaching a message box and set a break point just after the message box line in the App Constructor, I can just see the message box when launching my app and that's all. – Jonathan Mub Nice Sep 10 '18 at 21:03
  • When you dismiss the message box by clicking OK that should hit the break point in your code? Set the break point to the first instruction after the message box? – Stein Åsmul Sep 10 '18 at 21:06
  • You need debug binaries to be able to set breakpoints. If they are release builds there will be no debugging symbols in the files. – Stein Åsmul Sep 10 '18 at 21:20
  • They are debug builds – Jonathan Mub Nice Sep 10 '18 at 21:48
  • You open your source code that built the debug binaries in question, and from that Visual Studio session - with the right source version active - you attach to the message box showed from the launching binary after installation. Then the debugging symbols in the binaries and the source code will be compatible. – Stein Åsmul Sep 10 '18 at 21:51
  • I finally saw my problem with the debug binaries. My App launches now after fixing that problem. So great! Thanks a lot – Jonathan Mub Nice Sep 12 '18 at 08:13
  • Great news. Please share any details you feel may be helpful for others, but obviously don't post sensitive data - happens. – Stein Åsmul Sep 12 '18 at 08:15
0

After closely following Stein's guidelines on binary debugging (which took a little time to complete since it's my first time), I attached a box message to the execution sequence of my application (precisely in the constructor of the App class of my application WPF), then a break point directly on the instruction that follows the message box. I then generated the application, recreated the msi and then installed the msi. After launching the executable from the desktop shortcut, the message box appeared. I entered my source code before clicking on the OK button of the message box, I attached the process of my application (Debug -> Attach to process). The validation of the message box returned to me on Visual Studio, I was able to follow step by step the portion of the code until falling back on the small flat.

  • Hi Jonathan, can you tell us what the exact problem was? Not sure what "*falling back on the small flat*" means? Normally we use comments or updating of the original question to add details. Adding an answer yourself is usually only done if you got no acceptable answers and want to inform others of the solution you ended up with. All kinds of conventions, yes. – Stein Åsmul Sep 12 '18 at 08:39
  • Okay. I am sorry. This is my first time posting a problem here. My little problem is that I had just added a new application parameter during my last modifications that could not be taken into account by the new executable, because the new exe continued to use the old parameter file without the value of the new parameter. – Jonathan Mub Nice Sep 12 '18 at 11:41
  • No worries at all. Good that it is sorted. I added a quick summary to my answer since it is set as accepted. So people can immediately see what it was, and the answer can potentially be useful for others even after a quick skim. – Stein Åsmul Sep 12 '18 at 11:49