Search code examples
c#.netwcfoffice365ms-office

Making an installer for an Office Add-in with a WCF service reference


I'm trying to build a series of MS Office add-ins that all link to with a WCF service. I built an installer using Wix on Visual Studio which installs the add-ins and the service host app.

When I try to launch the add-ins I get an error as follows:

Could not find default endpoint element that references contract 'ServiceReference1.IAppCore' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I tested the service with another app and it seems to be running perfectly, however I cannot get it to connect with the Office add-ins.

Has anyone come accross this issue?


Solution

  • Thanks for directing me towards an answer.

    Actually, after deploying the add-ins I realized it was attempting to read the actual Office app's app.config file (i.e. Microsoft Office\Office16\EXCEL.EXE.config, etc.) instead of my own

    The solution to this problem is, in the end, extremely simple.

    In the Wix Product.wxs code the manifest registry entry needs to be prefixed with "file:///"

    So in my case it fixed the issue by changing from this entry:

    
        <Component Id="Excel_Registry_Manifest">
            <RegistryValue 
                Id="RegKey_Manifest_XLS" Root="HKCU"
                Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn"
                Name="Manifest"                   
                Value="[INSTALLFOLDER]ExcelAddIn.vsto|vstolocal"
                Type="string" KeyPath="yes" />
    
    

    to this one:

    
        <Component Id="Excel_Registry_Manifest">
            <RegistryValue 
                Id="RegKey_Manifest_XLS" Root="HKCU"
                Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn"
                Name="Manifest"                   
                Value="file:///[INSTALLFOLDER]ExcelAddIn.vsto|vstolocal"
                Type="string" KeyPath="yes" />
    
    

    I did this with all the add-ins and they're running perfectly now.

    Thanks a lot!