This article Article We will discuss the interoperability between C # And com. This article consists of two parts: the first part describes what is com, and the second part describes how to apply COM in. NET Framework.
Part 1: Component Object Model (COM)
Component
Component is not anotherBut can be embedded into otherProgramReusable binary software. It interacts with other programs through a common interface provided, allowing two different applications written in any language to communicate.
Importance of component
A program developed today consumes a long time andDifficult,Because of the high maintenance cost, we cannot replace the old version with the new version. The solution to this problem is to reuse component.
Solution
The solution to this problem is to replace many programs with the original functions and encapsulate them into a common function. In this way, the client can call this universal function to achieve reuse. In our project, we created five applications so that other users can simply apply them to various languages.
COM framework
To enable interoperability among other applications, you must follow certain rules and provide a standard interface. In this way, we only need a standard framework instead of who developed it.
Com is like green printing
If all applications follow the interoperability standard, Applications created by different people can operate on each other, so we can develop all the applications that we need. Microsoft has defined a standard model that allows different applications to call each other. This model involves COM. It provides interfaces for calling different program solutions to each other. Both the called Program and the called program must follow the com rules. The action of COM is like printing in green. It only provides the theoretical program interface and does not include its solution.
Microsoft COM
When we use the window Registrar to register a com or DCOM object, we must reference the guid of the 128-bit unique identifier of each object. When a client application executes a com or DCOM objectRegistryUse guid to reference its object. Another feature of COM is that it has no language dependency. Both the COM Client and COM Object share the same layout and behavior, so you don't have to worry about it.The language in which we use to develop this COM. COM, which has no special language dependency, allows a system that consists of multiple components to be developed in different languages. It doesn't matter which language we use to develop com. (... Illustrates the characteristics of COM and the benefits of no language dependency)
A Component Interface
Microsoft IDL
The basic concept of COM and DCOM is interfaces. An interface allows the client to communicate with one object. If we define interfaces such as VB, we must use Microsoft's Interface Definition Language (IDL). This IDL must use MicrosoftInterface Definition Language compiler (midl ).
Guid
Each interface we define in a COM object containsUniversally unique identifier (UUID ),OSIs to useThis generates a guid. When a client program executes a COM object of an interface, the application will reference its UUID. An interface is a license for communication between the client and the COM object.