Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   VSTO Com-add in prevents Outlook Notes from closing first time (http://www.outlookbanter.com/add-ins-outlook/46732-vsto-com-add-prevents-outlook.html)

Rowland Fong Lip April 23rd 07 02:54 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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


Ken Slovak - [MVP - Outlook] April 24th 07 02:24 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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 wrote in
message ...
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



PShah May 1st 07 09:13 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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


Ken Slovak - [MVP - Outlook] May 1st 07 11:17 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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" wrote in message
oups.com...
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



PShah May 3rd 07 08:55 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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


Ken Slovak - [MVP - Outlook] May 4th 07 04:29 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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" wrote in message
oups.com...
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



PS May 8th 07 04:25 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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


Ken Slovak - [MVP - Outlook] May 8th 07 10:44 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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...b;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" wrote in message
ups.com...
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



PS May 9th 07 09:59 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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.



Ken Slovak - [MVP - Outlook] May 9th 07 11:39 PM

VSTO Com-add in prevents Outlook Notes from closing first time
 
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" wrote in message
ps.com...
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...b;EN-US;929593 in the
section on Some methods no longer work in the Inspector.Close...



All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com