In Windows API Code Pack for .NET Framework, many methods of COM Interop interfaces 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);
Documentation for MethodImplOptions.InternalCall
value says:
The call is internal, that is, it calls a method that is implemented within the common language runtime.
Documentation for MethodCodeType.Runtime
says:
Specifies that the method implementation is provided by the runtime.
But, if I understand correctly, neither statement is correct. IShellItem
is implemented in shell32.dll, according to MSDN. shell32.dll is not a part of CLR. What's interesting, not all methods have the MethodImplAttribute
. IShellFolder
does, IShellLinkW
doesn't, IShellLibrary
does, IPersistStream
doesn't etc.
Why is MethodImplAttribute
applied to some of the COM Interop interfaces? What does it mean in this case and how does it modify behavior of interop?