问题描述
在NET库许多方法在本土code实现的。那些来自于框架本身都标有 [MethodImpl(MethodImplOptions.InternalCall)]
。那些来自一些非托管的DLL都标有 [的DllImport]
(如 [的DllImport(KERNEL32.DLL)]
)。到目前为止,没有什么不寻常。
不过,虽然写回答另一个问题,我发现有标有很多方法[的DllImport(QCall)]
。他们似乎是净的内部实现(如 GC._Collect()
)。
我的问题是:究竟 [的DllImport(QCall)]
是什么意思?在 [的DllImport(QCall)]
和 [MethodImpl(MethodImplOptions.InternalCall)]
这是一个古老的线程。由于CoreCLR现在开源GitHub上;如果有人仍然在寻求答案,这里是<一个href="https://github.com/dotnet/coreclr/blob/0c88c2e67260ddcb1d400eb6adda19de627998f5/Documentation/mscorlib.md#calling-from-managed-to-native-$c$c">official文档:
然后继续在小标题:
- <一个href="https://github.com/dotnet/coreclr/blob/0c88c2e67260ddcb1d400eb6adda19de627998f5/Documentation/mscorlib.md#choosing-between-fcall-qcall-pinvoke-and-writing-in-managed-$c$c">Choosing FCALL,QCall,P / Invoke的,写在管理code之间
- QCall功能特性
举例:
- QCall示例 - 管理部分
- QCall示例 - 未受管理的部分
Many methods in the .Net library are implemented in native code. Those that come from the framework itself are marked with [MethodImpl(MethodImplOptions.InternalCall)]
. Those that come from some unmanaged DLL are marked with [DllImport]
(e.g. [DllImport("kernel32.dll")]
). So far nothing unusual.
But while writing answer for another question, I discovered there are many methods marked with [DllImport("QCall")]
. They seem to be internal implementation of .Net (e.g. GC._Collect()
).
My question is: What exactly does [DllImport("QCall")]
mean? What is the difference between [DllImport("QCall")]
and [MethodImpl(MethodImplOptions.InternalCall)]
?
This is an old thread. Since CoreCLR is now open-sourced on GitHub; if someone is still seeking the answer, here is the official documentation:
And then it continues in subheadings:
with examples:
这篇关于什么是[的DllImport(&QUOT; QCall&QUOT;)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!