0

I have a Word AddIn which uses one setting to retrieve information from a webservice. This setting is stored in de settings section of the project (see image)

enter image description here

To be able to change this setting after the application is compiled, the access modifier is set to public. When I compile the application and use it in Word, I only have to change the ConfigURL in de [applicaitonname].dll.config. This works perfectly, the new URL is applied when trying to retrieve information from another webserivce address (URL).

In this project, I also have a Wix project to create an MSI for this AddIn. Now when I use the MSI to install the AddIn on a computer and after the installation, I change the ConfigURL, the new value is not applied, it still uses the value which was set when creating the MSI.

does anyone know if it is possible to create an MSI for deployment, and still able to change settings values in the config file after installation?

Stephan
  • 463
  • 2
  • 7
  • 22

2 Answers2

0

I assume that your Wix project installs the AddIn in the Program Files folder. If that's the case then most likely your user doesn't have the write permissions to this folder. You can either adjust your Wix project to setup necessary permissions to the AddIn's folder or deploy your configuration file to a different location e.g. %APPDATA%\Roaming\[AppName].

Alexey Andrushkevich
  • 5,992
  • 2
  • 34
  • 49
  • The AddIn is installed in the programs folder, and it is possible to change values in the config file, but somehow the value is nog used. The AddIn still uses the value which was used at compile time. So somehow it is protected in some way. – Stephan Oct 06 '20 at 13:10
  • What path to the manifest file did you set in the Windows registry? Does it end with "|vstolocal"? – Alexey Andrushkevich Oct 07 '20 at 15:27
  • yes that is correct. It looks like: – Stephan Oct 07 '20 at 19:15
0

From what I've found the VSTO customization DLLs are always loaded from a temporary folder location and not from the original location irrespective of whether ClickOnce cache is used or not. The location of the temporary folder is the Shadow copy folder of .NET framework which is mentioned under the registry key HKCU\Software\Microsoft\Fusion\DownloadCacheLocation.

Shadow Copy is a feature where DLLs can be updated while they are being used. To implement this feature, DLLs are copied to a temporary location when they are being used so that DLL at original location can be updated.

The Shadow copy feature has been used in VSTO from the initial version and there is no way to disable it. Shadow copy can be disabled for .NET AppDomain while creating an AppDomain but in the case of VSTO customization, the developer has no control over the way AppDomain is created and hence cannot configure the behavior.

In order to load a configuration file, it must be located in the same folder where the assembly is loaded from. Unfortunately, your config file does not get copied to the shadow cache so it seems it uses some hardcoded values.

In order to solve this issue, you can explicitly load a configuration file from the installation folder. Take a look at this answer for more information.

Alexey Andrushkevich
  • 5,992
  • 2
  • 34
  • 49