Currently I'm storing the settings for my custom addins in the registry but this seems like a kludge. I was wondering if there was an official place to store add-in settings. My preference would be to store them where Visual studio stores settings so they can be exported and imported easily.
Is it possible to store add-in settings with Visual Studio settings or is there a better way?
EDIT
My original answer to this topic had a couple of issues I discovered after years of using it. I've included it below for completeness but here is my updated thoughts on this.
The use of application settings is not version safe in a VSIX. The location of the stored setting file path in part includes the version string and hashes of the executable. When Visual Studio installs an official update these values change and as a consequence change the setting file path. Visual Studio itself doesn't support the use of application settings hence it makes no attempt to migrate this file to the new location and all information is essentially lost. The supported method of settings is the WritableSettingsStore. It's very similar to application settings and easy enough to access via SVsServiceProvider
public static WritableSettingsStore GetWritableSettingsStore(this SVsServiceProvider vsServiceProvider) { var shellSettingsManager = new ShellSettingsManager(vsServiceProvider); return shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); }
Original Answer
The most straight forward way is to use .Net's Application Settings infrastructure to store any settings. It's a mature framework with designer support for adding a settings infrastructure to your project.
It however does not integrate with Visual Studio's Import / Export settings infrastructure. Getting that working is a very involved process that includes registering yourself as a VSPackage, implementing a settings schema, etc ... I generally find it's really not worth the trouble of getting running (never succeeded)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With