简体   繁体   English

Outlook Addin的参数

[英]Parameters for outlook addin

I'm developing an outlook addin using C#. 我正在使用C#开发一个Outlook插件。

I want my addin to use parameter's file (XML, for example). 我希望我的插件使用参数的文件(例如XML)。

What is the best way to implement that? 最好的实现方法是什么?

Store parameters in xml file somewhere in file system? 将参数存储在xml文件中文件系统中的某个位置? Or using resources? 还是使用资源? Or is it possible to use .config file like it's done for windows applications? 还是可以像Windows应用程序一样使用.config文件? 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! 感谢您的任何建议!

Well, it depends... 这要看情况...

You may consider your VSTO based add-in as a regular .Net application. 您可以将基于VSTO的加载项视为常规的.Net应用程序。 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. 考虑使用辅助线程,因为IO操作可能需要一些时间才能完成。 It is up to you which way is to choose. 选择哪种方式取决于您。

I'd highly recommend NOT to use the project settings as if your outlook project was just any old .net app. 我强烈建议不要使用项目设置,就像您的Outlook项目只是任何旧的.net应用程序一样。 According to this rather obscure article, it is not supported: http://blogs.msdn.com/b/rprabhu/archive/2005/06/29/433979.aspx 根据此晦涩的文章,不支持此文章: 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). 我最初尝试将设置保存在项目设置(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). 我遇到的最大问题(VS中的其他一些小错误)是,每当我需要发布包含附加设置的Outlook加载项的新版本时,都无法强制创建新的user.config文件(使用新设置),而无需在我的MSI版本中做一些真正令人讨厌的解决方法(更像是黑客)。 The underlying reason is that the project settings ties the user.config file to not your assembly BUT THE VERSION OF OUTLOOK! 根本原因是项目设置将user.config文件与您的程序集联系在一起,但前景版本! So if the version of Outlook never changes, you can't get a fresh user.config file. 因此,如果Outlook的版本从未更改,则无法获得新的user.config文件。

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. 如果必须再次执行此操作,则只需创建一个专用的设置类,然后在关闭时将其序列化到用户的AppData文件夹,并在启动时将其反序列化为一个对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM