|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
The gcManagedToUnmanaged managed debugging assistant (MDA) causes a garbage collection whenever a thread transitions from managed to unmanaged code.
If an unmanaged component is not reference counting a managed COM object correctly, then the runtime could collect a managed object exposed to COM when the unmanaged component still holds a reference to the object. The runtime calls Release during garbage collections, so if the user component uses the object before the garbage collection occurs, then it will not yet have been collected. This is the source of the nondeterminism.
Enabling this assistant reduces the time between when the object is eligible for collection and Release is called, helping to track down which unmanaged component first tries to access the collected object.