Add-in configuration settings, best practices

Add-in Express™ Support Service
That's what is more important than anything else

Add-in configuration settings, best practices
 
mani g




Posts: 66
Joined: 2009-06-09
Hello,

I am working on an Outlook add-in, that will be published using ClickOnce deployment.

My app has settings that ship with the app, as well as user settings that the app writes to persist user data.

To accomplish this, I have been using the "Settings.settings" and "App.config" file properties that .Net provides:

Properties.Settings.Default["MyParameter"] = "MyValue";
Properties.Settings.Default.Save();

After doing some reading ... it appears that these configuration modules are more for standalone applications rather than add-ins or DLLs. So, my code is working, but I'm worried that it is not the best way to approach this and could lead to problems down the line. For example, I am seeing that the user-level settings are being written to a strange place (in my case, "C:/Documents and Settings/Administrator/Local Settings/Application Data/Microsoft_Corporation/C__Documents_and_Settings_Path_dpnycfd34lw0l20a4ljojfoq5biqtlf5/12.0.6514.5000/user.config".

Am I taking the wrong approach? What is the recommended way to persist user's configuration data in a ClickOnce, ADX.Net, C# Outlook add-in?

Thanks!
Posted 21 May, 2010 13:46:18 Top
Martin Bayly




Posts: 41
Joined: 2007-10-05
We were using the .NET settings framework too, and noticed the same thing that you noticed. The issue we had with this approach is that the path your settings are written to is tied to the Outlook version (in your case 12.0.6514.5000).

We found that when a user installed Outlook updates, their user settings were lost and a new file was written to a path named based on the latest Outlook version. We had some info in the user.config that it would have been pretty bad to lose, so we decided to take control of the writing of the app settings ourselves by implementing our own System.Configuration.IApplicationSettingsProvider.

But to be honest, I think this was more trouble than it was worth and I think it would have been better to just ditch the .NET settings framework and write our settings to our own custom XML config file at a fixed location.

Martin
Posted 21 May, 2010 17:16:48 Top
Eugene Astafiev


Guest


Hello guys,

First of all, thank you for sharing your knowledge, Martin :)

But to be honest, I think this was more trouble than it was worth and I think it would have been better to just ditch the .NET settings framework and write our settings to our own custom XML config file at a fixed location.


This is a painless approach ;)
Posted 24 May, 2010 04:53:34 Top
Nicholas Hebb


Guest


I have been using the "Settings.settings" and "App.config" file properties


Thanks for sharing this. I'm porting my add-in to .Net and that was the path I was going to take.
Posted 24 May, 2010 06:23:54 Top
mani g




Posts: 66
Joined: 2009-06-09
Thanks guys for the info.

Particularly the part about settings being lost when updating Outlook -- you just saved me a world of pain!!!!

Warm regards,
Mani
Posted 25 May, 2010 09:26:24 Top