guaranteee automation kills_handle events

D

Devhead

1) want to kill my automation server processes when i'm done with them.
i.e., want to make sure that my word and outlook processes that are
displayed in task manager are disposed of when i'm done. i set to null in
code but that doesn't kill process.

2) how do handle events in outlook and potentially word. need to create a
custom event for when the outlook email message closes either by send email
or user closing form.

thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

Devhead,

For #1, you will have to make sure that you call the static
ReleaseComObject method on the Marshal class, passing every reference that
you get from COM. The reason for this is that every object in word and
outlook usually has a reference to the parent, so you have to be diligent in
releasing them. Unfortunately, those object models have huge hierarchies,
which means that every time you access a property, it is returning a new COM
object that you have to call ReleaseComObject on.

Needless to say, you can not just set to null. You need to explicitly
dispose of the object.

As for handling events, there should be events exposed through the
objects in the Primary Interop Assemblies which you are interacting with
Word and Outlook. Either that, or events should be exposed through the
results of running TLBIMP on those dlls.

Hope this helps.
 

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