Re: Very Odd Behavior - Using a form on Outlook 2003 AddIn

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Ken,

I am using the setup project that VS 2005 builds for me to install the
AddIn. When i click Install on the project the add in gets installed, but if
i open Tools -> Advanced Options -> COM Add Ins, the add in does't appear on
the list. Isn't that strange? The Disabled Items list is also empty, before
and after i run the add in for the first time.
Can be a problem related to the install process?

The invocation of the ShowDialog() method can put my handlers out of scope?
If i comment that line, everything works fine.
Here's how i setup the handlers:

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;

Outlook._Application obj = (Outlook._Application)application;
obj.Application.ItemSend += new
ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}

I configured the add in to load when the host application starts.






"Ken Slovak - [MVP - Outlook]" wrote:

When it doesn't fire is the addin actually disconnected? You can check that
in the COM Add-Ins dialog on the Advanced Options page of the Tools, Options
dialog. You can also check in Help, About, Disabled Items.

I think it might be more likely that your handlers are going out of scope.
Are you adding them to a hashtable or declaring them with a scope that will
let them live for as long as Outlook is running?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Miguel Lopes" <Miguel Lopes@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:79460AEF-B167-4D58-A222-0D741A16E197@xxxxxxxxxxxxxxxx
Hi,

I am developing a Outlook 2003 Add In, using Visual Studio 2005 and Shared
Add In project template with C#.
The Primary Interop Assemblies for Office 2003 are also installed.
The goal of the addin is to provide the user that sends an email the
ability
to save it to disk. For that i am trapping the ItemSend
event as follows:

public void OnConnection(object application, Extensibility.ext_Co....
{
....
Outlook._Application obj = (Outlook._Application)application;
obj.Application.ItemSend += new
ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
....
}

In order to provide user interaction with the addin, i added to the
project
a standard Windows Form ( WhereToSaveForm.cs )
and in the addin event handler code i put the following code:

MessageBox.Show("Saving");
WhereToSaveForm formSave = new WhereToSaveForm();
formSave.ShowDialog();

In order to test, i just added a button to the form, with a click event
handler, that justs closes the form:

this.Close();

When i send an email the following happen:

1) The message box is shown, saying: "Saving";
2) The form is loaded and shown;
3) Click on form button;
4) The form is closed;
5) Email is sent;

But when i repeat the procedure ( without closing Outlook ):

1) The message box is not shown;
2) The form is not loaded and obviously not shown;
3) The email is sent;

It seems that for some reason my addin gets unloaded or somehow the event
handler is not invoked.

I tracked down the problem to the following line:

formSave.ShowDialog();

if i comment this line, the event is always called, no matter how many
messages are sent ( the message box is always shown ).

In order to discover the problem i tested the following:

1) See if any exception was thrown that could cause the add in to unload -
No exception was thrown;
2) Try to reproduce the implementation of the message box, since with
MessageBox object the event is always fired - Without success;
3) Use Dispose() and Close() from the addIn ItemSend event handler, to get
the form closed - Without success;

Any ideas on this odd behavior?

Best Regards,
Miguel Lopes



.



Relevant Pages

  • Re: Interop or VSTO or ?
    ... You can't just install a PIA, ... If you want to develop for Outlook 2003 you need that installed. ... A VSTO addin for 2003 will run in 2007 but won't handle the ribbon, custom task panes, etc. ...
    (microsoft.public.outlook.program_addins)
  • Re: A program is trying to access email addresses you have stored
    ... To prevent the PDFMaker COM Addin from loading, ... Diane Poremsky [MVP - Outlook] ... Google and Other Search Engines (Visual QuickStart Guide) ... I think the only thing is to customise the install ...
    (microsoft.public.outlook.installation)
  • Re: outlook addin setup problem - created using vsto
    ... Where are you developing that addin, is it on a machine with Outlook 2003 or 2007? ... You need to develop it on a machine with Outlook 2003 and then in your installer check for the correct PIA's on the target machine depending on the installed Outlook version. ... i have added setsecurity project to my solution. ... i want to get my add-in only if i install it not if i build the solution. ...
    (microsoft.public.outlook.program_forms)
  • RE: Unable to run Outlook 2000 com addin built via .NET/VS 2003
    ... I have tried to install the addin on "clean" machines, ... The full "history" of the addin is as follows... ... still worked when I sent a copy to my boss. ... I'll try and create a "blank" Outlook addin and see what happens. ...
    (microsoft.public.vsnet.setup)
  • Re: Very Odd Behavior - Using a form on Outlook 2003 AddIn
    ... You can check that in the COM Add-Ins dialog on the Advanced Options page of the Tools, ... Are you adding them to a hashtable or declaring them with a scope that will let them live for as long as Outlook is running? ... The goal of the addin is to provide the user that sends an email the ability ... and in the addin event handler code i put the following code: ...
    (microsoft.public.office.developer.com.add_ins)