.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

COM Basics - Important Points

Posted By:Bablu Bablu       Posted Date: May 07, 2010    Points: 25    Category: General    URL: http://www.dotnetspark.com  

This article gives an overview of COM and its basic functionalities.
 

IUNKNOWN

1)Base interface of COM. Every interface directly or indirectly derived from this interface
2)Provides three methods AddRef, QueryInterface, Release
3)AddRef increments the reference count to the object
4)Release decrements the reference count to the object
5)QueryInterface obtains Pointer to the object.
6)QueryInterface returns E_NOINTERFACE if requested object was not found and also nullify its out parameter.

IDISPOSE

1)exposes objects, methods and properties to programming tools and other applications that support Automation.
2)The object's properties and methods can be accessed using IDispatch::GetIDsOfNames and IDispatch::Invoke.

CoCreateInstance and CoCreateInstanceEX

1)CocreateInstance is used to create object in local system and it allows only one object to create at a time.
2)CoCreateInstanceEx is used to create object in remote system and it allows to create multiple objects based on single CLSID

Aggregation

1)Is the mechanism in which outerobject exposes the methods of inner object
2)We can get a pointer to the inner interface, calling QueryInterface of the outer object with IID of the inner interface.

Moniker

1)An object that implements IMoniker interface.
2)provides information to uniquely identify a COM object.

OLE vs COM

1)OLE is build on top of COM
2)COM is a specification, while OLE is a particular implementation of this specification

COM vs DCOM

1)introduced several improvements for distributed environment, such as MULTI_QI (multiple QueryInterface()), security

contexts
2)DCOM demonstrated importance of surrogate process (you cannot run in-proc server on a remote machine).
3)DCOM introduced a load balancing
4)DCOM extends COM

Dual Interface

1) which supports both IDISPATCH and V-Table based interfaces
2)You may have two dual interfaces in one class. you cannot work with two dual interfaces at the same time.

Marshalling By Value

1) Instead of accessing an object remotely, it is possible to copy the static state of the object and create a new object with the same state information on the caller side.
2) not involve network round trips.

multi-threaded apartment (MTA) and Single-threaded apartment (STA)

1) In STA, all calls will be made by the same thread. In MTA, COM object can be accessed by many threads simultaneously
2) A process can have only one MTA, but many STAs

In-Proc means COM object that implemented as DLL and supposed to be hosted by a container. When you have to instantiate the in-proc object remotely, you may use DLLHost.exe application that was design specially for this purpose.

IDL

Interface Definition Language to describe COM interfaces

Is there a way to register in-proc server without regsvr32.exe?

Yes. Call DllRegisterServer() from the client. Do not forget to call DLLUnregisterServer() from the same client. You may also use Registrar object for the same purpose or use direct manipulation of the windows registry.
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend