How to keep single Redemption.rdosession object through entire add-in application

0

In my outlook add-in, I create new rdoSession object and set mapi object each time I need to make use of the rdoSession objects as following.

Redemption.RDOSession session = Redemption.RedemptionLoader.new_RDOSession(); session.MAPIOBJECT = outlookApplicaitonObject.Session.MAPIOBJECT;

Is there a possibility to have one static Redemption.rdoSession object globally, so I can call it whenever I want to make use of it ? I declared a static RdoSession object and it throws following exception sometimes.

Unable to cast COM object of type 'System.__ComObject' to interface type 'Redemption.IRDOSession'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{E54C5168-AA8C-405F-9C14-A4037302BD9D}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))

What is the reason for this and is it possible to do what I'm trying to do ?

c#
outlook
outlook-addin
outlook-redemption
comobject
asked on Stack Overflow Jun 10, 2016 by Nilaksha Perera • edited Jun 10, 2016 by Dmitry Streblechenko

1 Answer

1

Are you using multiple threads? You will need to create a an instance of RDOSession on each thread - see http://www.dimastr.com/redemption/faq.htm#Threads for more details.

You can store the value of Namespace.MAPIOBJECT in a separate variable (so that IMAPISession is marshalled between threads, and not any OOM or Redemption objects), and then set RDOSession.MAPIOBJECT property to that variable on each thread on thread-local instances of RDOSession.

answered on Stack Overflow Jun 10, 2016 by Dmitry Streblechenko • edited Jun 10, 2016 by Dmitry Streblechenko

User contributions licensed under CC BY-SA 3.0