Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Outlook.exe - how to kill?

Geek News

Outlook.exe - how to kill?
cookiesncreamychoc[ at ]hotmail.com 9/18/2006 1:49:44 PM
Hi All,

Of all the posts out there, Outlook.exe doesnot disappear from task
manager mainly due to add-ins still referencing it.

I open outlook manually and the add-in loads, performs its functions
and then when I close outlook the Outlook.exe process gracefully
terminates. Yes, it does terminate all by itself so that would imply
the add-in cleans up after itself. Correct?

The problem arises when I open Outlook from C# (VS 2005) application
(to the calendar). The Outlook.exe lingers in the process list long
after the process is killed. The code is as follows:
Outlook.ApplicationClass oOutlook = new
Outlook.ApplicationClass();
Outlook.Application appOutlook = new Outlook.Application();
Outlook.MAPIFolder oCalendar;
Outlook.Explorer oEx = oOutlook.ActiveExplorer();

oCalendar = null;

if (oEx != null)
{
oCalendar =
oOutlook.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
oEx.CurrentFolder = oCalendar;
((Outlook._Explorer)oEx).Activate();
}
else
{
oCalendar =
appOutlook.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
oCalendar.Display();
}

oCalendar = null;
oEx = null;
appOutlook = null;
oOutlook = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}

In the add-in, I handle the Explorer.Close and Inspector.Close events
and when ApplicationObject.Explorers.Count() = 0 and
ApplicationObject.Inspectors.Count() = 0, here is what I do...
oCalendarItem = Nothing
oDeletedItem = Nothing
oExplorer = Nothing
oInspector = Nothing
cInspector = Nothing
addInInstance = Nothing
Marshal.ReleaseComObject(addInInstance)
ApplicationObject = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()

What am I doing wrong plzzzz???

Thanx

Re: Outlook.exe - how to kill?
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 9/18/2006 10:23:44 PM
Is this an Outlook addin or not? You say it is and then you say it isn't. If
it is an addin why are you creating a new Outlook application object instead
of using the one passed to you in OnConnection?

If this is a standalone application there would be no ActiveExplorer unless
Outlook was running already.

If a standalone app and Outlook wasn't running you'd probably need to logon
to NameSpace and I'd touch the store to make sure it fully loads. I'd also
check to see if I had started Outlook and if so I'd issue an Outlook.Quit
command when I was done.

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


<cookiesncreamychoc[ at ]hotmail.com> wrote in message
news:1158587384.722451.37180[ at ]i42g2000cwa.googlegroups.com...
[Quoted Text]
> Hi All,
>
> Of all the posts out there, Outlook.exe doesnot disappear from task
> manager mainly due to add-ins still referencing it.
>
> I open outlook manually and the add-in loads, performs its functions
> and then when I close outlook the Outlook.exe process gracefully
> terminates. Yes, it does terminate all by itself so that would imply
> the add-in cleans up after itself. Correct?
>
> The problem arises when I open Outlook from C# (VS 2005) application
> (to the calendar). The Outlook.exe lingers in the process list long
> after the process is killed. The code is as follows:
> Outlook.ApplicationClass oOutlook = new
> Outlook.ApplicationClass();
> Outlook.Application appOutlook = new Outlook.Application();
> Outlook.MAPIFolder oCalendar;
> Outlook.Explorer oEx = oOutlook.ActiveExplorer();
>
> oCalendar = null;
>
> if (oEx != null)
> {
> oCalendar =
> oOutlook.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
> oEx.CurrentFolder = oCalendar;
> ((Outlook._Explorer)oEx).Activate();
> }
> else
> {
> oCalendar =
> appOutlook.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
> oCalendar.Display();
> }
>
> oCalendar = null;
> oEx = null;
> appOutlook = null;
> oOutlook = null;
> GC.Collect();
> GC.WaitForPendingFinalizers();
> GC.Collect();
> }
> }
>
> In the add-in, I handle the Explorer.Close and Inspector.Close events
> and when ApplicationObject.Explorers.Count() = 0 and
> ApplicationObject.Inspectors.Count() = 0, here is what I do...
> oCalendarItem = Nothing
> oDeletedItem = Nothing
> oExplorer = Nothing
> oInspector = Nothing
> cInspector = Nothing
> addInInstance = Nothing
> Marshal.ReleaseComObject(addInInstance)
> ApplicationObject = Nothing
> GC.Collect()
> GC.WaitForPendingFinalizers()
> GC.Collect()
>
> What am I doing wrong plzzzz???
>
> Thanx
>

Re: Outlook.exe - how to kill?
cookiesncreamychoc[ at ]hotmail.com 9/18/2006 11:13:13 PM
Yes it is an add-in.
Then there is an application that launches outlook and expects the
add-in to work.

So as long as I am manually opening outlook the add-in works and
outlook.exe terminates by itself.
However, when I use the application (which has a button to launch
outlook), outlook opens the add-in works but when I manually close it,
outlook.exe remains. (I cannot use quit becuase the application is only
meant to open outlook not close it, closing is a manual operation.)

Outlook launches from the application if outlook.exe doesnot exist and
works as expected but if outlook.exe exists and outlook is not open,
outlook is launched but the add-in doesnot display. Quite obviously as
I cleaned up in the add-in on explorer.count=0 and inspector.count=0.

So what should I do for outlook.exe to terminate without manual
intervention when outlook is launched from the application???

Thnx

Ken Slovak - [MVP - Outlook] wrote:
[Quoted Text]
> Is this an Outlook addin or not? You say it is and then you say it isn't. If
> it is an addin why are you creating a new Outlook application object instead
> of using the one passed to you in OnConnection?
>
> If this is a standalone application there would be no ActiveExplorer unless
> Outlook was running already.
>
> If a standalone app and Outlook wasn't running you'd probably need to logon
> to NameSpace and I'd touch the store to make sure it fully loads. I'd also
> check to see if I had started Outlook and if so I'd issue an Outlook.Quit
> command when I was done.
>
> --
> 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
>
>
> <cookiesncreamychoc[ at ]hotmail.com> wrote in message
> news:1158587384.722451.37180[ at ]i42g2000cwa.googlegroups.com...
> > Hi All,
> >
> > Of all the posts out there, Outlook.exe doesnot disappear from task
> > manager mainly due to add-ins still referencing it.
> >
> > I open outlook manually and the add-in loads, performs its functions
> > and then when I close outlook the Outlook.exe process gracefully
> > terminates. Yes, it does terminate all by itself so that would imply
> > the add-in cleans up after itself. Correct?
> >
> > The problem arises when I open Outlook from C# (VS 2005) application
> > (to the calendar). The Outlook.exe lingers in the process list long
> > after the process is killed. The code is as follows:
> > Outlook.ApplicationClass oOutlook = new
> > Outlook.ApplicationClass();
> > Outlook.Application appOutlook = new Outlook.Application();
> > Outlook.MAPIFolder oCalendar;
> > Outlook.Explorer oEx = oOutlook.ActiveExplorer();
> >
> > oCalendar = null;
> >
> > if (oEx != null)
> > {
> > oCalendar =
> > oOutlook.Application.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
> > oEx.CurrentFolder = oCalendar;
> > ((Outlook._Explorer)oEx).Activate();
> > }
> > else
> > {
> > oCalendar =
> > appOutlook.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
> > oCalendar.Display();
> > }
> >
> > oCalendar = null;
> > oEx = null;
> > appOutlook = null;
> > oOutlook = null;
> > GC.Collect();
> > GC.WaitForPendingFinalizers();
> > GC.Collect();
> > }
> > }
> >
> > In the add-in, I handle the Explorer.Close and Inspector.Close events
> > and when ApplicationObject.Explorers.Count() = 0 and
> > ApplicationObject.Inspectors.Count() = 0, here is what I do...
> > oCalendarItem = Nothing
> > oDeletedItem = Nothing
> > oExplorer = Nothing
> > oInspector = Nothing
> > cInspector = Nothing
> > addInInstance = Nothing
> > Marshal.ReleaseComObject(addInInstance)
> > ApplicationObject = Nothing
> > GC.Collect()
> > GC.WaitForPendingFinalizers()
> > GC.Collect()
> >
> > What am I doing wrong plzzzz???
> >
> > Thanx
> >

Re: Outlook.exe - how to kill?
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 9/19/2006 2:03:37 PM
Does your application close itself down after starting Outlook? You're going
to have to do a lot of debugging to see what references to Outlook you're
leaving hanging. There's not much else I can tell you, if nothing is hanging
as a reference Outlook would be closing down.

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


<cookiesncreamychoc[ at ]hotmail.com> wrote in message
news:1158621193.015822.6700[ at ]i3g2000cwc.googlegroups.com...
[Quoted Text]
> Yes it is an add-in.
> Then there is an application that launches outlook and expects the
> add-in to work.
>
> So as long as I am manually opening outlook the add-in works and
> outlook.exe terminates by itself.
> However, when I use the application (which has a button to launch
> outlook), outlook opens the add-in works but when I manually close it,
> outlook.exe remains. (I cannot use quit becuase the application is only
> meant to open outlook not close it, closing is a manual operation.)
>
> Outlook launches from the application if outlook.exe doesnot exist and
> works as expected but if outlook.exe exists and outlook is not open,
> outlook is launched but the add-in doesnot display. Quite obviously as
> I cleaned up in the add-in on explorer.count=0 and inspector.count=0.
>
> So what should I do for outlook.exe to terminate without manual
> intervention when outlook is launched from the application???
>
> Thnx

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