What does MethodImplAttribute(InternalCall, Runtime) do for methods of COM Interop interfaces?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 13:58:19

It is just a side-effect from the way the Microsoft programmer obtained the interface declaration. Some of the shell interfaces are available in a type library, like IShellItem, so the easiest way to get them into source code is to run Tlbimp.exe to generate the interop library and a disassembler to decompile the assembly into C# code. Which also brings in the extra attributes that Tlbimp.exe generates, like [MethodImpl].

Other interfaces are not available in a type library, like IShellLinkW and IPersistStream, nor can a type library be generated from the IDL so the programmer had no choice but to type them in himself. He skipped the unnecessary stuff.

And no, [MethodImpl] isn't critical here. These are interface types so there is no method anyway. Tlbimp.exe just isn't terribly sophisticated about it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!