COM 与 WinRT 的关系

Relation between COM and WinRT

我没有清楚地了解 similarities/differences 或 COM(组件对象模型)和 WinRT[=20 之间的关系本身=](Windows 运行时)。

据我了解,它们都是为了提供 "runtime engine" 使组件能够通信...那是 CLR(公共语言运行时)吗?

WinRT 附带 Windows8 以启用适用于多种语言的通用平台。

我在这里没有得到的是,WinRT 是否取代了 COM? 它们是一样的吗?

COM 是 "just" 一个 binary-interface 软件组件标准(来自 wikipedia)。 没有运行时,没有 base/utility 类 集(好吧,有一些,比如交叉 thread/process 封送处理、注册表、COM+,但是没有它你也可以做 COM)。

COM 在 Windows 中绝对无处不在,用于客户端和服务器,因为在其内心深处,它是 "just" 一个 vtable binding contract

WinRT 是一个完全成熟的 API 在 COM 之上(同样,没有引擎)。所以,它自带了一组base类。它实际上非常适合 UI 应用程序(Windows 商店)。 WinRT 还附带了一组 services (metadata, type system, deployment/store, etc.). An useful WinRT introduction is available here: WinRT demystified

CLR is the execution engine that powers .NET programs. It can be used on clients and servers. For example, the garbage collector is implemented there. In fact, it's been ported to other platforms than Windows these last years as an open source project: CoreCLR Windows CLR 仅将 COM 用于其部分工作,主要用于与 Windows 平台通信。 WinRT 不使用 CLR。​​

Windows内核是用C语言写的,Windows组件是用C++写的。当您的前端应用程序(比如 Visual Basic 或 c#)需要与这些组件保持一致时,您需要某种类型的 mechanism/standard 来与这些组件交互。这种交互机制//标准称为COM。

根据微软 "COM is a platform-independent, distributed, object-oriented system for creating binary software components that can interact"。

请注意,您不需要 .Net run-time 即可与 COM 组件交互。可以使用 Visual Basic、VC++ 等旧语言调用它。

现在大多数在 .Net 中开发的应用程序和 .Net 应用程序必须与 windows 组件交互。微软在windows组件之上构建了一个层(API),使.Net应用程序可以顺利地与windows组件进行交互。这一层就是 WinRT。作为前端开发人员,您需要与 WinRT 交互,WinRT 将代表您与 Windows 组件交互。

对于.Net 应用程序,WinRT 最终将取代COM。但对于非 .Net 应用程序,COM 仍然存在。