Concept of COM in C#


Introduction

COM in C#

COM  stands for "Common object modal".
com is a kind of specification to make the component reusable. All the active components are by default com components. com is a concept-its practical implementation is activex.

========= ABOVE CONCEPT WAS USED IN VB/VC++/C++=========

In .NET for this purpose we use assembly

Assembly is the component modal for .NET.

Assembly

1.
It contains the meta data (data about data).
2. Project details: Name/version/author/creation date/creation time/ and IL (Intermediate language).

Assembly have two parts:

1. Manifest : Name, Author, Creation date, Time.
2. Body : IL

To view assembly: C:\>ILDASM A.EXE

Types of assembly

1.
Private assembly:for same project
2. Public or shared assembly:for any project

Assembly comes in the form of

.DLL (Dynamic link library)
.EXE (Executable file)

Difference between .dll & .exe

DLL                                    EXE
 
1. Not self executed                 1. Self executable
2. No Main()                            2. Main()
3. In Process                           3. Out Process
   (Execute in client memory)         (Hold separate memory)
4. light weight                          4. heavy weight

How to make a .dll :

1.Class library : There will be Class( method/constructor/property)
2.
Window control library : There will be user defined control.

How to make a class library

1.
Open visual studio-->File menu- select new project- select C# class library-name-location then OK.

fig-1.1.gif

fig-1.gif

2. Coding

fig-2.gif

3. Build (After that .dll will create)

Another example

Windows control library

1.
Open visual studio -File menu-new project -C#-windows form control library-name--ok

fig-3.gif


Example
: Digital clock

Take label and timer form Toolbox.

fig-4.gif

2.
Coding

fig-5.gif

3. Bulid solution

Up Next
    Ebook Download
    View all
    Learn
    View all