Category Archive for: Interoperability

Primary Interop Assemblies

A primary interop assembly is an assembly that is already prepared by the vendor of .theCOM component. This makes it easier to use the COM component. A primary interop assembly is a runtime-callable wrapper that might differ from an automatically generated RCW. You can find primary interop assemblies in the directory <program files>\Microsoft .NET\ Primary Interop Assemblies.…

Read More →

Creating a Runtime Callable Wrapper

You can now use the COM component from within .NET. To make this possible, you must create a runtime callable wrapper (RCW). Using the RCW,the .NET client sees a .NET object instead of the COM component; there is no need to deal with the COM characteristics because this is done by the wrapper. An RCW hides the…

Read More →

Using a COM Component from a .NET Client

To see how a .NET application can use a COM component, you first have create a COM component, Creating COM components is not possible with C# or Visual Basic 2005 you need either visual Basic 6.0 or C++ (or any other language that supports COM). This chapter uses the Active Template library (A’TL) and C++, A short note about…

Read More →

Marshaling

Data passed from .NET to the COM component and the other way around musl be converted to the corresponding representation, This mechanism is also known as marshaling. What happens here depends on the data type of the data that is passed: You have to differentiate between blittable and nonblittable data types. Blittable data types have a common representation with…

Read More →

Error Handling

With .NET,errors are generated by throwing exceptions. With the older COM technology, errors are defined by returning HRESULTvalues with the methods. An HRESULTvalue of S_OK means that the method was successful. If a more detailed error message is offered by the COM component, the COM component implements the interface ISupportErrorlnfo, where not only an error message but…

Read More →

Threading

COM uses apartment models to relieve the programmer of having to deal with threading issues. However, this also adds some more complexity. Different apartment types have been added with different releases of the operating system. This section discusses the single-threaded apartment and the multithreaded apartment. Single-threaded Apartment The single-threaded apartment (STA) was introduced with Windows…

Read More →

Registration

.NET distinguishes between private and shared  “Assemblies.” With COM, all components are globally available by a registry configuration. All COM objects have a unique identifier that consists of a 12S-bit number and is also known as class ID (CLSID). The COM API call to create COM objects, CoCreatelnstance ( I,just looks into the registry to…

Read More →

Data Types

For dual and dispatch interfaces, the data types that can be used with COM are restricted to a list of autemation-compatible data types. The Invoke method of the IDispatch interface accepts an array of VARIANTdata types. The :VARIANTis a union of many different data types, such as BYTE,SHORT,LONG, FLOAT,DOUBLE,BSTR, IUnknown*, IDispatch*, and so on. VARIANTShave…

Read More →

Method Binding

How a client maps to a method is defined WIth the terms early and late binding. Late binding means that the method to invoke is looked for during runtime. .NET uses the System. Reflection namespace to make this possible .COM uses the IDispatch interface discussed earlier for late binding. Late binding is possible with dispatch and dual interfaces. With…

Read More →

Interfaces

Interfaces are the heart of COM. They distinguish between a contract used between the client and the object, and the implementation. The interface (the contract) defines the methods that are offered by the component and that can be used by the client. With .NET, interfaces play an important part, too. COM distinguishes among three interface types: custom,…

Read More →

Back to Top