Problem when hooking Application.Reminder event

M

Mariano Rivera

Hello everyone:

I am having a problem with a VSTO 2005 SE outlook addin I am developing for
Office 2003.

Basically whenever I save a new appointment and then open it up and click on
the Save and Close button (withouth changing anything), Outlook displays a
confirmation dialog saying that the appointment has changed and if I want to
send an update.

I narrowed the problem to what looks to be an issue when hooking the
Outlook.Application.Reminder event. If I remove the hook to this event then
outlook behaves correctly which is really weird. Also if I restart Outlook it
will allow me to save the appointment withouth asking me for the "send
update" confirmation dialog.

Steps to reproduce the problem:
* Create a new VSTO 2005 SE Outlook addin.
* On ThisAddIn_Startup() method add a handler to Application.Reminder event.
* Press F5 to launch Outlook and the addin.
* Go to the calendar.
* Create a new appointment.
* Change the title, subject and add an invitee.
* Click on Send button in the toolbar.
* Reopen the newly create appointment double clicking on it.
* Press on the Save And Close button.

Outlook will then display a confirmation dialog with the following message:
"You have changed the meeting "title". Would you like to send this updated
meeting to the attendees now?"

If I comment the Application.Reminder line in the addin and recreate all the
previous steps the confirmation dialog isnt displayed and the appointment
just closed.

Any clues of what might be going on here ?

Thanks in advance,

Mariano
 
K

Ken Slovak - [MVP - Outlook]

I recall a similar problem a while ago with another top level event, I
forget which one. It turned out that due to bugs in the PIA's and Interop
that if you handled one event at that level then all events at that level
fired even if you didn't subscribe to those events.

See if putting dummy event handlers for the other events at that level, for
example ItemSend(), fixes the problem.
 
M

Mariano Rivera

Hi Ken:

Thanks for the reply.

I just tried your suggestion but it didnt fix the issue. Interesting enough
I even discovered while adding the other event handlers that the problem is
not associated specifically with the Application.Reminder event. Basically
every event in the Application object level will produce the error, if
defined.

I will try creating a shared addin to see if we can narrow the problem to an
Outlook object model problem or a VSTO problem. I will post my results here.

Thanks for your help.

Mariano
 
K

Ken Slovak - [MVP - Outlook]

Thanks, Dmitry, that's the article I was thinking of.

Although he does go overboard with his recommendations, you really have to
be sure that the object or related object won't still be referenced anywhere
else in your code since that will release all local and global references to
that object by killing its RCW.

I've found problems where I released a local copy of an Inspector for
example in an Inspector wrapper and that killed a reference to the same
Inspector held in another module in a completely different object variable
with completely different scope.
 
M

Mariano Rivera

Thanks for the support guys but I am still unable to make it to work.

Below is a really simple sample I am using to test this (I am omitting using
statetements for simplicity sake):

/**************************************/

public partial class ThisAddIn
{
private Outlook.Application outlookApp;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookApp = this.Application;

outlookApp.Reminder += new
Outlook.ApplicationEvents_11_ReminderEventHandler(Application_Reminder);
outlookApp.ItemSend += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
outlookApp.AdvancedSearchComplete += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_AdvancedSearchCompleteEventHandler(Application_AdvancedSearchComplete);
outlookApp.AdvancedSearchStopped += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_AdvancedSearchStoppedEventHandler(Application_AdvancedSearchStopped);
outlookApp.MAPILogonComplete += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_MAPILogonCompleteEventHandler(Application_MAPILogonComplete);
outlookApp.NewMail += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailEventHandler(Application_NewMail);
outlookApp.NewMailEx += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx);
outlookApp.OptionsPagesAdd += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_OptionsPagesAddEventHandler(Application_OptionsPagesAdd);
outlookApp.Startup += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_StartupEventHandler(Application_Startup);
}
/**************************************/

Then for each handler code I am freeing the arguments using something like
this:

/**************/

void
Application_OptionsPagesAdd(Microsoft.Office.Interop.Outlook.PropertyPages
Pages)
{
Marshal.ReleaseComObject(Pages);
Pages = null;
}

/**************/

Of course in the ThisAddIn_Shutdown I am releasing the application member var.

As you can see this is a really simple sample but nevertheless I am still
having the same issue as before.

Any clues will be really appreciated.

Best regards.

Mariano
 
K

Ken Slovak - [MVP - Outlook]

Take a look at each event handler and see if what you're releasing is an
object that needs to be used again without re-instantiating it. Other than
that I have no idea why you're having the problem. It might take opening a
support case with MS possibly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top