Search code examples
.netwixexcel-addins

Trouble reading from the configuration file after installing it with Wix installer


In my Excel Add-in project i am reading some data from the app.config file(renamed to iFMExcelAddIn.dll.config), but while installing it through Wix,my add-in is not reading the data from the config file, even though i am installing the config file as well with the installer. I don’t know what i am missing here. i don’t have much experience using Wix Installer, and all the googling didn’t give nay fruitful results.

I suppose it is something to do with the way i am installing the config file.The following is the code i am using to add the config file. It is last second component in the component group. Also the path of AddinFILe is ../iFMExcelAddIn/$(Configuration)/. I hope this much info helps let me know if you need more.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

<Component Id="iFMExcelAddIn_vsto_Component">
    <File Id="iFMExcelAddIn_vsto" KeyPath="yes"
          Name="iFMExcelAddIn.vsto" Source="$(var.AddinFiles)"></File>
</Component>

<Component Id="iFMExcelAddIn_dll_manifest_Component">
   <File Id="iFMExcelAddIn_dll_manifest" KeyPath="yes"
          Name="iFMExcelAddIn.dll.manifest" Source="$(var.AddinFiles)">     </File>
  </Component>

  <Component Id="MSOfficeToolsCommon_dll_Component">
    <File Id="MSOfficeToolsCommon_dll" KeyPath="yes"
          Name="Microsoft.Office.Tools.Common.v4.0.Utilities.dll"
          Source="$(var.AddinFiles)"></File>
  </Component>

  <Component Id="MSOfficeToolsExcel_dll_Component">
    <File Id="MSOfficeToolsExcel_dll" KeyPath="yes"
          Name="Microsoft.Office.Tools.Excel.dll"
          Source="$(var.AddinFiles)"></File>
  </Component>

  <Component Id="iFMExcelAddIn_dll_Component" >
    <File Id="iFMExcelAddIn_dll" KeyPath="yes"
          Name="iFMExcelAddIn.dll" Source="$(var.AddinFiles)" />
  </Component>


  <Component Id="iFMExcelAddIn_dll_Config_Component" >
    <File Id="iFMExcelAddIn_dll_Config" KeyPath="yes"
          Name="iFMExcelAddIn.dll.config" Source="$(var.AddinFiles)" />
  </Component>

  <Component Id="iFMServiceDll_Component">
    <File Id="iFMServiceDll" Name="IFM.Service.dll" Source="$(var.AddinFiles)" SelfRegCost="1">
    </File>
  </Component>

</ComponentGroup>


Solution

  • After almost two days of searching around and learning how the app.config works, I found a solution to this problem. Actually, after deploying the excel add-in I found that it was trying to read the app.config file from the path ---> Install Drive>:\Program Files\Microsoft Office\Office12\EXCEL.EXE.config. I even thought of putting my config entries into the excel.exe.config files to make it work but as it is not the right way, I found that we need to change a registry entry where we specify the vsto addin path. The change seems so silly

    The manifest registry entry needs to be prefixed with file:///.ie instead of "[TARGETDIR]ExcelAddIn.vsto|vstolocal": we need to use "file:///[TARGETDIR]ExcelAddIn.vsto|vstolocal":