Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: VSTO Com-add in prevents Outlook Notes from closing first time

Geek News

VSTO Com-add in prevents Outlook Notes from closing first time
Rowland Fong Lip 4/23/2007 1:54:02 PM
Hi

I have developed a C# com addin in VSTO 2005 / Office Professional 2003 and
deployed it to a XP pc with Office Standand 2003 (SP2 installed).

It all works fine except has this strange behaviour. If you create or open
an Outlook Note, you have to click on the X multiple times to close the item.

Has anyone experienced this before?

Thanks
Rowland

Re: VSTO Com-add in prevents Outlook Notes from closing first time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 4/24/2007 1:24:00 PM
I don't know if this has anything do with it but deploying a VSTO addin is
only supported for Office 2003 Professional or above. Also, are you doing
anything with any Notes objects (IPM.StickyNote)? Notes are brain dead and
never should be worked with in code.

--
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


"Rowland Fong Lip" <Rowland Fong Lip[ at ]discussions.microsoft.com> wrote in
message news:1731DB44-2F08-43FF-8A21-2816B63EC9A1[ at ]microsoft.com...
[Quoted Text]
> Hi
>
> I have developed a C# com addin in VSTO 2005 / Office Professional 2003
> and
> deployed it to a XP pc with Office Standand 2003 (SP2 installed).
>
> It all works fine except has this strange behaviour. If you create or open
> an Outlook Note, you have to click on the X multiple times to close the
> item.
>
> Has anyone experienced this before?
>
> Thanks
> Rowland
>

Re: VSTO Com-add in prevents Outlook Notes from closing first time
PShah <pratikrshah[ at ]gmail.com> 5/1/2007 8:13:26 PM
Rowland / Ken

I have the exact same scenario as Rowland. Have a C# addin for Outlook
(using VSTO 2005 not SE) and using Outlook 2003 SP2.

Ken - In my case - there is no programming done for notes. It is more
like wiring up the inspectors_NewInspector and inside that i check if
item being opened is mail item. If it is then - all the logic but if
not then just do nothing. Notes ofcourse falls inside the else block.

Recently I opened a case with Microsoft regarding this and am
currently working with them on this issue.

It seems that this issue is a bug (not related to coding in C#). Also
with the above logic - there have been some issues with calender
items. Again as mentioned above - I dont program for calender items -
so they all fall in else block but it seems that the inspector doesnt
release the reference even though i force Garbage collection.

Code in the else block (if not mail Item)

{
Marshal.ReleaseComObject(inspector)
inspector = null;

GC.WaitForPendingFinalizers();
GC.Collect();
}

Rowland - it also seems that depending on the Outlook version you are
running - u see a flavour of this issue.
My own developement machine has Outlook version 11.8120.8122 SP2 and
when i try to click "x" multiple times on the note - it crashes
outlook and restarts.
A test machine has Outlook version 11.8120.8107 SP2 and there the
behavior is that I need to click "x" twice before it closes the note.
It doesnt crash Outlook.

On speaking to the MS representative - it seems that could be a bug in
the product (VSTO or Outlook) but they are still looking into it.

Rowland - have u also seen issues for calender items (i am assuming
that u are also working with mail items).

Regarding notes - i will update this chain if i get a fix and it
works.........

Thanks

Re: VSTO Com-add in prevents Outlook Notes from closing first time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 5/1/2007 10:17:50 PM
I don't understand.

Why are you releasing the Inspector object? It's local to the scope of
NewInspector. I use VSTO 2005 and VSTO 2005 SE and never had to release the
Inspector passed in NewInspector. I use Inspector wrapper classes to wrap
all Inspectors other than Notes usually, but that's a different story.

What exactly is your case with MS about?

The usual wisdom regarding programming Notes is don't do it, they're brain
dead. That goes back to the Outlook 97 days and hasn't changed at all. A
Notes.Inspector object is especially deadly.

--
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


"PShah" <pratikrshah[ at ]gmail.com> wrote in message
news:1178050406.334219.172850[ at ]y80g2000hsf.googlegroups.com...
[Quoted Text]
> Rowland / Ken
>
> I have the exact same scenario as Rowland. Have a C# addin for Outlook
> (using VSTO 2005 not SE) and using Outlook 2003 SP2.
>
> Ken - In my case - there is no programming done for notes. It is more
> like wiring up the inspectors_NewInspector and inside that i check if
> item being opened is mail item. If it is then - all the logic but if
> not then just do nothing. Notes ofcourse falls inside the else block.
>
> Recently I opened a case with Microsoft regarding this and am
> currently working with them on this issue.
>
> It seems that this issue is a bug (not related to coding in C#). Also
> with the above logic - there have been some issues with calender
> items. Again as mentioned above - I dont program for calender items -
> so they all fall in else block but it seems that the inspector doesnt
> release the reference even though i force Garbage collection.
>
> Code in the else block (if not mail Item)
>
> {
> Marshal.ReleaseComObject(inspector)
> inspector = null;
>
> GC.WaitForPendingFinalizers();
> GC.Collect();
> }
>
> Rowland - it also seems that depending on the Outlook version you are
> running - u see a flavour of this issue.
> My own developement machine has Outlook version 11.8120.8122 SP2 and
> when i try to click "x" multiple times on the note - it crashes
> outlook and restarts.
> A test machine has Outlook version 11.8120.8107 SP2 and there the
> behavior is that I need to click "x" twice before it closes the note.
> It doesnt crash Outlook.
>
> On speaking to the MS representative - it seems that could be a bug in
> the product (VSTO or Outlook) but they are still looking into it.
>
> Rowland - have u also seen issues for calender items (i am assuming
> that u are also working with mail items).
>
> Regarding notes - i will update this chain if i get a fix and it
> works.........
>
> Thanks
>

Re: VSTO Com-add in prevents Outlook Notes from closing first time
PShah <pratikrshah[ at ]gmail.com> 5/3/2007 7:55:41 PM
Ken

So here is the code in the inspectors_NewInspector method (which is
wired up in the ThisApplication_Startup)


private void inspectors_NewInspector(Outlook.Inspector inspector)
{
try
{
Object objCurrentItem = inspector.CurrentItem;
if (objCurrentItem is Outlook.MailItem)
{
// Enters this if loop if the item is Mail Item and my
complete logic is here since my plugin
// only has programming done for MailItems
}
else
{
Marshal.ReleaseComObject (objCurrentItem);
objCurrentItem = null;

GC.WaitForPendingFinalizers( );
GC.Collect( );
}
}
catch (Exception ex)
{
// Logging to local Event Logs
}
}

So Ken - as you see from above code - everything which is not an
MailItem falls into the else block (calender items, notes) etc.

I Dont do any programming for notes and totally agree with you that
they are brain-dead.

But with the above code - any item which is not MailItem falls into
the else loop (notes, calender, tasks) and even though I am cleaning
up - apparently the notes still holds a reference for inspector and so
when I click on "x" - it does close the note. When i click multiple
times on the "x" it sometimes closes the note or even crashes Outlook

What are your thoughts....

Thanks

Re: VSTO Com-add in prevents Outlook Notes from closing first time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 5/4/2007 3:29:33 PM
I wouldn't release anything at all in NewInspector, it's just not needed and
probably will cause problems. I use late binding to get the Class of the
Inspector.CurrentItem using code like this:

object item = Inspector.CurrentItem;
Type _type;
_type = item.GetType();
object[] args = new Object[] { };
Outlook.OlObjectClass _class;

_class = (Outlook.OlObjectClass)_type.InvokeMember("Class",
BindingFlags.Public | BindingFlags.GetField | BindingFlags.GetProperty,
null, item, _args);

That lets me check the item.Class. If it's a type I want to handle I do so,
if not the NewInspector code does nothing else. It releases nothing. I don't
even release item, all that I do is surround the tests for Class in
try{}...catch{} blocks.

--
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


"PShah" <pratikrshah[ at ]gmail.com> wrote in message
news:1178222141.458104.261860[ at ]n59g2000hsh.googlegroups.com...
[Quoted Text]
> Ken
>
> So here is the code in the inspectors_NewInspector method (which is
> wired up in the ThisApplication_Startup)
>
>
> private void inspectors_NewInspector(Outlook.Inspector inspector)
> {
> try
> {
> Object objCurrentItem = inspector.CurrentItem;
> if (objCurrentItem is Outlook.MailItem)
> {
> // Enters this if loop if the item is Mail Item and my
> complete logic is here since my plugin
> // only has programming done for MailItems
> }
> else
> {
> Marshal.ReleaseComObject (objCurrentItem);
> objCurrentItem = null;
>
> GC.WaitForPendingFinalizers( );
> GC.Collect( );
> }
> }
> catch (Exception ex)
> {
> // Logging to local Event Logs
> }
> }
>
> So Ken - as you see from above code - everything which is not an
> MailItem falls into the else block (calender items, notes) etc.
>
> I Dont do any programming for notes and totally agree with you that
> they are brain-dead.
>
> But with the above code - any item which is not MailItem falls into
> the else loop (notes, calender, tasks) and even though I am cleaning
> up - apparently the notes still holds a reference for inspector and so
> when I click on "x" - it does close the note. When i click multiple
> times on the "x" it sometimes closes the note or even crashes Outlook
>
> What are your thoughts....
>
> Thanks
>

Re: VSTO Com-add in prevents Outlook Notes from closing first time
PS <pratikrshah[ at ]gmail.com> 5/8/2007 3:25:05 PM
Ken

I will definitely try your suggested code today and see the results.

For the notes case though - as I had mentioned above that I have a
case open with Microsoft - it has been boiled down to a bug. Below is
the exact MS response which I got yesterday:

mS Response:
I am working with the Dev team regarding the StickyNote close problem.
It appears to be an issue introduced by a backport we made in Outlook
2003 for a fix in Outlook 2007 regarding the Item_Close event. The
VSTO 2005 AddinLoader for Outlook 2003 is listening for the close
event on StickyNotes and canceling the close. I am awaiting some
research from the dev team and I will update you when I hear back from
them.

Thanks

Re: VSTO Com-add in prevents Outlook Notes from closing first time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 5/8/2007 9:44:59 PM
Thanks for following up. I'm not surprised that the fix in Outlook 2003
broke things. The documented result is listed in
http://support.microsoft.com/default.aspx?scid=kb;EN-US;929593 in the
section on Some methods no longer work in the Inspector.Close...

--
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


"PS" <pratikrshah[ at ]gmail.com> wrote in message
news:1178637905.503407.230400[ at ]h2g2000hsg.googlegroups.com...
[Quoted Text]
> Ken
>
> I will definitely try your suggested code today and see the results.
>
> For the notes case though - as I had mentioned above that I have a
> case open with Microsoft - it has been boiled down to a bug. Below is
> the exact MS response which I got yesterday:
>
> mS Response:
> I am working with the Dev team regarding the StickyNote close problem.
> It appears to be an issue introduced by a backport we made in Outlook
> 2003 for a fix in Outlook 2007 regarding the Item_Close event. The
> VSTO 2005 AddinLoader for Outlook 2003 is listening for the close
> event on StickyNotes and canceling the close. I am awaiting some
> research from the dev team and I will update you when I hear back from
> them.
>
> Thanks
>

Re: VSTO Com-add in prevents Outlook Notes from closing first time
PS <pratikrshah[ at ]gmail.com> 5/9/2007 8:59:13 PM
Sort of the final update which I got from MS:

Lot of discussion going between Outlook team and the VSTO team (after
we discovered the issue and pointed it to them) and they are planing
to roll the fix in a hotfix which might be relased in the near
future.

Hopefully that will resolve this issue.


Re: VSTO Com-add in prevents Outlook Notes from closing first time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 5/9/2007 10:39:28 PM
Good to know, thanks.

--
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


"PS" <pratikrshah[ at ]gmail.com> wrote in message
news:1178744353.131254.99150[ at ]w5g2000hsg.googlegroups.com...
[Quoted Text]
> Sort of the final update which I got from MS:
>
> Lot of discussion going between Outlook team and the VSTO team (after
> we discovered the issue and pointed it to them) and they are planing
> to roll the fix in a hotfix which might be relased in the near
> future.
>
> Hopefully that will resolve this issue.
>
>

Thanks for following up. I'm not surprised that the fix in Outlook 2003
broke things. The documented result is listed in
http://support.microsoft.com/default.aspx?scid=kb;EN-US;929593 in the
section on Some methods no longer work in the Inspector.Close...

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net