Question

In a custom action I am loading the .exe.config file via ConfigurationManager.OpenExeConfiguration(exePath) {This path is correct to the file}

I am doing this After="InstallFiles" and everything works in the install up to the point I try to call config.Save(); then the below error is returned and it all rolls back.

An error occurred loading a configuration file: Access to the path 'C:\Program Files (x86)...\rdayspic.tmp' is denied. (.exe.config).

Do I need to somehow get to the actual file and not a .tmp version, or follow some other pattern for accessing/modifying the config?

I read somewhere that I might need to pull the entire file in as a string basically and work the changes via search and replace but that seems way too cludgy to me...

Était-ce utile?

La solution

It sounds like you try to update the XML file (application configuration) during your product installation. If that's the case, you should take a look at XmlConfig element.

It has a number of advantages compared to custom action:

  • it is a part of WiX toolset and hence was thoroughly tested
  • its only purpose is to modify the XML
  • it's a matter of several lines of WiX code

So, don't invent the wheel and keep to the standard solutions as much as possible.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top