This article was previously published under Q304417
This article has been archived. It is offered "as is" and will no longer be updated.
An access violation (AV) may occur in the OLE DB Services layer whenever the _ATL_DEBUG_INTERFACES macro is defined within an Active Template Library (ATL) provider. When this occurs, the following error message is usually reported from the OLE DB client application:
Defining _ATL_DEBUG_QI and _ATL_DEBUG_INTERFACES when writing an ATL provider causes a QIThunk object to be created for each interface requested by way of a QueryInterface() call. The code in the OLE DB services causes the QIThunk to be freed prematurely, and any attempt to use that freed object results in an access violation.
Remove the _ATL_DEBUG_XXX definitions from any custom ATL provider that uses the OLE DB services.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
For additional information on using the OLE DB Provider Templates, see the Platform SDK documentation.