register eventhandler for Office 2013 event in vs 2010 by reflections in C# -
i have outlook 2010 add-in project written in c# using visual studio 2010.
since add-in overall working in outlook 2013 want make slight modification, prevent problems new inlineresponse feature in outlook 2013.
i want register eventhandler inlineresponse event without upgrading vs 2012 (because of removed installer project). read using reflections new events.
i don't exceptions, event doesn't trigger handler (oninlineresponse not called).
public partial class thisaddin { outlook.explorer _explorer; private void thisaddin_startup(object sender, system.eventargs e) { _explorer = application.activeexplorer(); addinlineresponsehandler(); } private void addinlineresponsehandler() { var einfo = _explorer.gettype().getevent("inlineresponse", bindingflags.public | bindingflags.instance); if (einfo != null) { var handler = delegate.createdelegate(einfo.eventhandlertype, this, this.gettype().getmethod("oninlineresponse", bindingflags.nonpublic | bindingflags.instance), false); einfo.addeventhandler(_explorer, handler); } } private void oninlineresponse() { system.windows.forms.messagebox.show("inlineresponse"); } }
any suggestions how might achieve desired behaviour?
gavin smyth (who wrote mentioned post using reflections) kind give me answer differences between our implementations:
the difference can spot between yours , mine oninlineresponse takes argument, newly created mail item - see http://msdn.microsoft.com/en-us/library/office/jj229061 - ie, method defined as:
private void oninlineresponse(object item) { ... }
Comments
Post a Comment