Using. NET components in COM applications

Source: Internet
Author: User

First, let's look at the relationship between today's topic and CLR interop, in our group, the term Interop contains four categories, namely P/invoke, Reverse P/invoke, COM interop, and Reverse COM interop. The first two concepts are through dynamic connection libraries (DLLs) in the native world and. NET world; the latter two concepts, as the name suggests, are dealing with COM. Where COM Interop is in the. NET application, Reverse COM interop refers to the use of. NET components in COM applications. The concept of some tongue twisters, reader first do not rush to throw, look at the following figure.

Some people may ask, COM technology has a long history,. Why do net programmers need to deal with it? The answer to the question is the word "component". For example, a few years ago a cow wrote a program that was extremely scalable, and he used COM to define the interface of the plugin as plainly as we wanted. NET to do this plugin ...

To write a. NET component for COM, you can refer to the following trilogy

1. Definition. NET interface, composing. NET class

2. Deployment. NET components

3. Compose COM client

The first step is often engaged. NET development friend is very familiar with, here give examples, no longer repeat.

Csc/target:library A.cs

Second, to deploy. NET component, this includes two aspects:

RegAsm A.dll/tlb

1. Export the type library. For COM applications, it knows only the type library, which is the binary "standard" that is followed for COM components. The/tlb option tells RegAsm to export the type library. We can use OLEView to view the contents of the TLB, as shown in the following figure, as previously defined. NET interfaces and classes are in them.

2. Put the DLL generated in step 2 in the registry. COM does not understand the concept of the GAC, but rather through the registry to query hkey_classes_root\cls_id\00000000-0000-0000-ffff-000000000004, observe the registry key, InprocServer32 the COM dynamic link library to the Mscoree.dll, which is the legendary gasket (SHIM), which is responsible for loading the common language runtime and finding the real. NET component----A.dll.

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.