PRB: Access Violation Using CDO in Multi-threaded COM Server

ID: Q236577


The information in this article applies to:


SYMPTOMS

When using CDO in a multi-threaded COM server, an access violation may occur on releasing the last object hosted by the server.


CAUSE

CDO uses messaging application programming interface (MAPI), and the first thread that uses MAPI in a process causes certain initialization actions to occur. These particular initialization actions do not reoccur when other threads use MAPI. When the original thread terminates, specific de-initialization actions happen within the server process, which may lead to problems with the other threads using MAPI.

For example, the following scenario illustrates how an access violation can occur:

A Microsoft Visual Basic 6.0 ActiveX EXE server has a class that creates a CDO session in its initialize event and releases it in its terminate event. A client application creates an instance (A) of this class and then a second instance (B). The client releases instance A and then releases instance B. This leads to the de-initialization of MAPI and the shutdown of the server process. During these activities an access violation occurs.


RESOLUTION

There are at least three ways in which you can avoid this problem:

Additional query words: crash error fault GPF IPF


Keywords          : kbCDO121 kbMsg kbGrpMsg kbDSupport 
Version           : WINDOWS:1.21
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: July 27, 1999