Share via


dirtyCastAndCallOnInterface MDA

The dirtyCastAndCallOnInterface managed debugging assistant (MDA) is activated when an early-bound call through a vtable is attempted on a class interface that has been marked late-bound only.

Symptoms

An application throws an access violation or has unexpected behavior when placing an early-bound call via COM into the CLR.

Cause

Code is attempting an early-bound call through a vtable via a class interface that is late-bound only. Note that by default class interfaces are identified as being late-bound only. They can also be identified as late-bound with the ClassInterfaceAttribute attribute with an AutoDispatch value ([ClassInterface(ClassInterfaceType.AutoDispatch)]).

Resolution

The recommended resolution is to define an explicit interface for use by COM and have the COM clients call through this interface instead of through the automatically generated class interface. Alternatively, the call from COM can be transformed into a late-bound call via IDispatch.

Finally, it is possible to identify the class as AutoDual ([ClassInterface(ClassInterfaceType.AutoDual)]) to allow early bound calls to be placed from COM; however, using AutoDual is strongly discouraged because of the versioning limitations described in ClassInterfaceAttribute.

Effect on the Runtime

This MDA has no effect on the CLR. It only reports data about early-bound calls on late-bound interfaces.

Output

The name of the method or name of the field being accessed early-bound.

Configuration

<mdaConfig>
  <assistants>
    <dirtyCastAndCallOnInterface />
  </assistants>
</mdaConfig>

See Also

Concepts

Diagnosing Errors with Managed Debugging Assistants

Reference

ClassInterfaceAttribute

Other Resources

Interoperability