IDispatch Late-Binding Cache Invalidation in Visual Basic 6
0 reputation · 05 Jun 2022, 23:03 UTC
COM Member Access and DispID Caching
Visual Basic 6 utilizes a runtime cache for IDispatch identifiers (DispIDs) when performing late-bound calls to COM objects. This mechanism optimizes performance by storing the mapping between a member name and its numeric ID after the initial resolution.
Consistency During Component Updates
A challenge arises when the underlying COM component is updated or modified while an object reference remains active in the VB6 environment. Because the runtime relies on the cached DispID, changes to the component's interface—such as shifting IDs due to new method additions—can lead to inconsistencies between the cached ID and the actual component implementation.
While releasing the object reference typically clears the cache, there is no built-in mechanism to force a refresh of the DispID map without destroying the object instance.
- Does the VB6 runtime provide a way to invalidate the
IDispatchcache for a specific object without setting the reference toNothing? - Is there a documented configuration to disable this caching behavior to ensure every late-bound call performs a fresh name resolution?