In the Windows API Code for the .NET Framework, many MethodImplAttribute COM methods are decorated with MethodImplAttribute , for example:
internal interface IShellItem { [PreserveSig] [MethodImpl( MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HResult BindToHandler( [In] IntPtr pbc, [In] ref Guid bhid, [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out IShellFolder ppv);
The documentation for MethodImplOptions.InternalCall says:
The call is internal, i.e. calls a method implemented in a common language environment.
The documentation for MethodCodeType.Runtime says:
Indicates that the implementation of the method is provided by the runtime.
But, if I understand correctly, not a single statement is correct. IShellItem implemented in shell32.dll , according to MSDN. shell32.dll is not part of the CLR. What are interesting, not all methods have a MethodImplAttribute . IShellFolder does, IShellLinkW does not, IShellLibrary does, IPersistStream not, etc.
Why is MethodImplAttribute applied to some COM Interop interfaces? What does this mean in this case and how does it change the interaction behavior?
source share