Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing a callback?

Status
Not open for further replies.

espar

Programmer
May 13, 2002
66
AU
Hi all :)

I am having problems removing a callback to Outlook selection object VS 2k3 - outlook 2k3 - outlook PIA and Office core.

Since VS doesnt seem to support debugging outlook as a remote app i am having trouble working out what is happening.

The add works fine - but the remove throws a
"Microsoft.Office.Interop.Outlook.ExplorerEvents_10_EventProvider.Remove_SelectionChange(ExplorerEvents_10_SelectionChangeEventHandler) Object reference not set to an instance of an object".

I thought the command finding the explorer was failing - so i made that global in the class - and set on startup - didnt fix tho.

// Outlook app
OI.NameSpace outlookNS = applicationObject.GetNamespace("MAPI");

// Get the explorer object
OI.Explorer Explorer = outlookNS.Application.ActiveExplorer();

add code - IF BUTTONPRESS:
Explorer.SelectionChange += new OI.ExplorerEvents_10_SelectionChangeEventHandler(this.updateDtrixUI);

ELSE REMOVE:
Explorer.SelectionChange -= new OI.ExplorerEvents_10_SelectionChangeEventHandler(this.updateDtrixUI);

 
Lol - it would but then i fear that Outlook would cease to function =p ie. you'd remove all callback methods from the selection change event...

Well after a day of head scratching and posting this morning - i just found my stupidity !@!

In the method which was being called from the handler i had left an assignment of the explorer object - which must have been getting set to some other part of Outlook - d'oh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top