Custom ConfigurationSectionHandlers in InstallerClasses

I’m writing an installer class for an MSI Setup Project, and find myself needing to manipulate my web.config containing a custom ConfigurationSection. This should be trivial seeing as my SectionHandler code is bundled with the rest of the application, but fails miserably on my GetSection() call, because the DLL containing it is unavailable to MSIEXEC, which runs from C:WindowsSystem32. What to do, what to do?

Several options:

1) Rather than using the custom ConfigurationSection, I can open my web.config as a standard XmlDocument and do the changes manually.

Pro: No depenencies.
Con: More complicated, untyped, more error-prone.

2) Copy my section handler DLL to %SystemRoot%System32 during installation.

Pro: Simple.
Con: Ugly, goes against the “Don’t touch System32” philosophy that serves us well.

3) Launch a new AppDomain whose BaseDirectory points to my bin path, and do all my config-mangling there.

Pro: Clean, strongly typed, etc.
Con: More work. Causes my relatively simple installer class to grow in size and complexity.


Right now, I’m leaning towards #2. Keeping it simple, even if ugly. After all, no-one really looks in System32, and uninstalling the application will uninstall those files as well. No harm done.

Anyone got any other approaches, mitigating factors or other suggestions?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.