.NET 组件和 COM 组件有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/688456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the Difference between .NET components and COM Components
提问by sivakumar
What is the Difference between .NET components and COM Components, sometimes we use .NET Components to include in our projects and sometimes we include COM reference. What is the idea behind?
.NET 组件和 COM 组件有什么区别,有时我们使用 .NET 组件来包含在我们的项目中,有时我们会包含 COM 引用。背后的想法是什么?
采纳答案by Mitch Wheat
.NET components are managed code (memory disposal is done for you)
.NET 组件是托管代码(内存处理已为您完成)
COMis an interface standard for software components. COM components are unmanaged code (memory disposal is performed using reference counting).
COM是软件组件的接口标准。COM 组件是非托管代码(使用引用计数执行内存处理)。
From here:
从这里:
How are COM and .NET related?
COM and .NET are complementary development technologies. The .NET Common Language Runtime provides bi-directional, transparent integration with COM. This means that COM and .NET applications and components can use functionality from each system. This protects your existing investments in COM applications while allowing you to take advantage of .NET at a controlled pace. COM and .NET can achieve similar results. The .NET Framework provides developers with a significant number of benefits including a more robust, evidence-based security model, automatic memory management and native Web services support. For new development, Microsoft recommends .NET as a preferred technology because of its powerful managed runtime environment and services.
COM 和 .NET 有什么关系?
COM 和.NET 是互补的开发技术。.NET 公共语言运行时提供与 COM 的双向、透明集成。这意味着 COM 和 .NET 应用程序和组件可以使用每个系统的功能。这可以保护您在 COM 应用程序中的现有投资,同时允许您以可控的速度利用 .NET。COM 和.NET 可以达到类似的结果。.NET Framework 为开发人员提供了许多好处,包括更强大、基于证据的安全模型、自动内存管理和本机 Web 服务支持。对于新开发,Microsoft 推荐 .NET 作为首选技术,因为它具有强大的托管运行时环境和服务。
回答by Hernán
COM components are unmanaged C++ code components designed to make software reusable at binary level. NET components are similar altough 1) they can be created on CLR-languages while COM components can be built with C++ only 2) They are meant to run under a managed runtime. I think those are essentialdifferences.
COM 组件是非托管 C++ 代码组件,旨在使软件可在二进制级别重用。NET 组件类似,但 1) 它们可以在 CLR 语言上创建,而 COM 组件只能使用 C++ 构建 2) 它们旨在在托管运行时下运行。我认为这些是本质的区别。
EDIT:
编辑:
C++ is the most "natural" language in COM, but COM components can be created in MANY languages. Thanks for the comments people.
C++ 是 COM 中最“自然”的语言,但 COM 组件可以用多种语言创建。感谢人们的评论。
回答by harpo
.NET components run in the CLR, whereas COM components are essentially native Windows DLL's.
.NET 组件在 CLR 中运行,而 COM 组件本质上是本机 Windows DLL。
.NET components also expose vastly more metadata than COM components. This redesign was undertaken in part to make components more interoperable. In particular, .NET components do not make platform-specific assumptions about data layout and calling conventions.
.NET 组件公开的元数据也比 COM 组件多得多。进行这种重新设计的部分原因是为了使组件更具互操作性。特别是,.NET 组件不会对数据布局和调用约定做出特定于平台的假设。
See Don Box.
见唐盒。
回答by Shoban
Some more information about this topic
有关此主题的更多信息
CCW : http://msdn.microsoft.com/en-us/library/f07c8z1c.aspx
CCW:http: //msdn.microsoft.com/en-us/library/f07c8z1c.aspx

