The interconnectivity between COM and. net

Source: Internet
Author: User
Author: Builder. com
Tuesday, January 14 2003 pm

 

The. NET platform was a major technical switch from the early days of COM. com has dominated the Microsoft world for many years. Although you can use. Net for new development, you still need to use some existing functions in the form of COM components. In this article, I will talk about some technologies for intercommunication between COM and. net.

Com to. Net: Technological Transformation

 

Although COM components and. NET components share the same. dll extension, they are essentially different .. The net component does not need to store the information related to it in the registry, but it saves the type information as metadata. This metadata is stored in the component itself. Furthermore, the. NET component is not based on the iunknown interface, and all COM objects expose this interface.

Code that exists in the form of COM is called unmanageable code (Unmanaged code), Because the execution of this Code cannot be managed by the Common Language Runtime Library (CLR. Code written using the. NET framework can be managed by CLR, so it is called manageable code (Managed code).

It is impractical to rewrite every piece of code in. net, because many functions exist in the form of COM. In addition, there are more code in the form of COM than. net, because. Net is a relatively new platform. For this reason, the demand for interconnectivity between COM and. NET is increasing .. Net Framework has a dedicated namespace for this purpose:System. runtime. interopservicesThe namespace provides classes that can be used to access COM from. net. Next, we will start by calling the COM object from. Net -- this is usually a required behavior.

Call COM object from. net
The code in the COM object is not executed by CLR. The mechanism for disclosing COM objects to. NET is as follows: COM objects are encapsulated inside the function class, which exposes COM objects as. NET components to CLR. This packaging function is the Runtime Library callable packaging function (RCW ).FigureAThis process is described.

Figure

Runtime Library callable packaging function (RCW)

This packaging function class acts as a bridge between unmanageable and manageable code, and all operations must pass through this class. The theory is enough. Let's see how to do this. The entire process of RCW generation is automatically handled by Visual Studio. NET.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.