c# - Outlook 2016 plugin AttachmentSelection Issue -


i have created outlook addin selected attachment details of attachment. , working fine in outlook 2010. when build outlook 2016, becomes null.

below code in thisaddin.cs:-

 private void thisaddin_startup(object sender, system.eventargs e)         {             system.reflection.assembly assemblyinfo = system.reflection.assembly.getexecutingassembly();             uri uricodebase = new uri(assemblyinfo.codebase);             string location = path.getdirectoryname(uricodebase.localpath.tostring());             var path = location.split(new string[] { "bin" }, stringsplitoptions.removeemptyentries);             var rootdir = path[0].tostring();             var forpermissionsrootdirectory = path.getdirectoryname(rootdir);             setpermissions(forpermissionsrootdirectory);              app = this.application;             app.attachmentcontextmenudisplay += new outlook.applicationevents_11_attachmentcontextmenudisplayeventhandler(app_attachmentcontextmenudisplay);//attach attachment context menu event//          }   void app_attachmentcontextmenudisplay(office.commandbar commandbar, outlook.attachmentselection selection)         {             selectedattachment = selection;             ribbonui.invalidatecontrolmso("contextmenuattachments");//will xml file data//          } 

and code in attachmentcontextmenu.cs:-

public void onopenmymotioncalendarbuttonclick(office.iribboncontrol control)         {             outlook.attachmentselection selection = thisaddin.selectedattachment;              if ((selection.count > 0))                 {                    //my further working                 }          } 

in selection , there null outlook 2016. please suggest do?

kind regards, ariel

i believe outlook developers added logic releasing passed parameter object (attachment). so, need gather required information in event handler because method ends object can destroyed. nobody can guarantee objects alive after event handlers fired. valid object in attachmentcontextmenudisplay event handler?

all outlook add-ins should systematically release references outlook objects when no longer needed. use system.runtime.interopservices.marshal.releasecomobject release outlook object when have finished using it. set variable nothing in visual basic (null in c#) release reference object. read more in systematically releasing objects article.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -