CPP/CLI 程序集和 CS/VB 程序集有什么区别?
我确实知道一些“基本”差异,但我心中仍然存在一些问题:
- 它们在运行时的性能有什么差异? //这个我真的很想知道。
- 为什么不能使用 C++/CLI 构建 MSIL 程序集?
- MSIL/CIL 程序集的 PE 代码(不是 .NET 的 PEKind)是什么? (C++/CLI 程序集与非托管二进制文件具有相同的 PE 代码,对吗?)
如有任何进一步的知识/答案,我们将不胜感激。
I do know some "basic" differences but there are still some questions in my mind:
- What's their difference in performance at runtime? //This I really wanna know.
- Why can't you build a MSIL assembly using C++/CLI?
- What's the PE code (Not the .NET's PEKind) of a MSIL/CIL assembly? (C++/CLI assemblies have the same PE Code than unmanaged binaries, right?)
Any further knowledge/answers are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C++/CLI 程序集可以包含本机代码,其潜力比托管代码具有更高的性能。 然而,本机代码和托管代码之间的转换(通常在调用本机类或本机 API 调用时)涉及一些自动生成的编组和装箱,这确实会占用一些周期。
至于你的第二个问题,你可以。 请查看 /clr:pure。
托管程序集和混合模式程序集都是 DLL,但它们扩展了 .NET 元数据。 纯 MSIL 程序集只是没有本机接口(尝试 dumpbin /exports C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Build.Tasks.v3.5.dll,然后是 ildasm 相同的文件)。
A C++/CLI assembly can contain native code, which has the potential to be more performant than managed code. However, the transitions between native and managed code (usually when calling into a native class, or a native API call) involves some automatically-generated marshalling and boxing, which can really suck up some cycles.
As to your second question, you can. Take a look at /clr:pure.
Managed and mixed-mode assemblies are both DLLs, but they have extended .NET metadata. Pure MSIL assemblies just don't have a native interface (try
dumpbin /exports C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Build.Tasks.v3.5.dll
, thenildasm
the same file).