Outlook hangs at Threading AddIn

Add-in Express™ Support Service
That's what is more important than anything else

Outlook hangs at Threading AddIn
Matthias Kwiedor



I need Thread support at my AddIn. For this i have a new Library which will be called up at AddIn start

new NewLibrary((Outlook.Application)HostApplication)

Everything works fine, but when i trie to access the Outlook.Application handler and close Outlook, the GUI closes but in the Taskmanager i have OUTLOOK and the TaskIcon won't close.

The Thread is closed and hangs not. Even i have now only one access to the Handler with

Outlook.NameSpace _ns = OutlookApp.GetNamespace("MAPI")

where OutlookApp is the reference from the AddIn.

Even a Marshal.ReleaseComObject(_ns) doesn't help. If i include Marshal.ReleaseComObject(OutlookApp) at the end of the Thread Outlook closes, but the Handler of the AddIn is destroyed.

Running without Thread works perfect.

I thought to add a releasing of the ComObjects at "AddInBeginShutdown", but this event never gets fired. I created a simple "Button" Toolbar without Add-In-Express and the thread worked fine and Outlook closed without any problems.

I tried giving over only the HostApplication object as reference, but this doesn't succeded too. After Releasing the Application ComObject (from HostAppliation) this object was Released too.

Maybe someone can help me!



Posted 17 Nov, 2004 09:39:05 Top
Eugene Starostin


Hello Matthias,

According to Add-in Express's Class Reference all its classes and their members are not thread safe. But we will see what can be done here. Your source code will allow us to do this faster :-)
Posted 17 Nov, 2004 09:48:30 Top
Sergey Grischenko

Add-in Express team

Posts: 7233
Joined: 2004-07-05
Hi Matthias,

Try to declare the _NameSpace as a private field in the CoreModule module, initialize the _NameSpace in the CoreModule constructor
(_NameSpace = OutlookApp.GetNamespace("MAPI");) and release the _NameSpace in the Dispose method of CoreModule. It should work. You'd better get some Outlook API interfaces before your thread is started. Just try to slightly reconstruct your code.
Posted 17 Nov, 2004 11:33:26 Top