Reputation: 3327
I'm developing an outlook addin using C#.
I want my addin to use parameter's file (XML, for example).
What is the best way to implement that?
Store parameters in xml file somewhere in file system? Or using resources? Or is it possible to use .config file like it's done for windows applications? How?
And then what is the best way to load parameters? On startup, or in build-in when my ribbon is actually activated?
Thanks for any advice!
Upvotes: 0
Views: 251
Reputation: 880
I'd highly recommend NOT to use the project settings as if your outlook project was just any old .net app. According to this rather obscure article, it is not supported: http://blogs.msdn.com/b/rprabhu/archive/2005/06/29/433979.aspx
I found this out the hard way as I initially tried saving my settings in the project settings (user.config). The the biggest issue I ran into (among some additional minor bugs in VS) is that whenever I needed to release a new version of my Outlook addin that contained additional settings, there was no way to force the creation of a fresh user.config file (with the new settings) without doing some real annoying workarounds in my MSI builds (more like a hack). The underlying reason is that the project settings ties the user.config file to not your assembly BUT THE VERSION OF OUTLOOK! So if the version of Outlook never changes, you can't get a fresh user.config file.
If I had to do it over again, I'd just create a dedicated settings class and then serialize it to the user's AppData folder at shutdown and deserialize to an object at startup.
Upvotes: 1
Reputation: 49395
Well, it depends...
You may consider your VSTO based add-in as a regular .Net application. The only thing I can suggest is to not load the config data in the Startup event handler. Consider using a secondary thread because the IO operatrions can take some time to finish. It is up to you which way is to choose.
Upvotes: 1