The Microsoft Component Model – – A curtain raiser

– Friday, Feb 06, 2004

“This is the first of the papers from The Spicit Seminars (in-house training sessions of Spicit Consulting), selected but periodic reports of which will be made available to our readers.”
“This summary has been prepared by Danny Jacob of a seminar conducted by Shijith Lal, Technical Director, Spicit Consulting.”


Programming using Static Libraries:

Static Libraries consist of a set of pre-compiled files containing functions and procedures that are most frequently used and those functions that are system related in nature. The main reason for using a static library is that the commonly used functions and procedures need not be rewritten over and over for different programs. The programmer needs to just include the library in his source code and call the functions or procedures directly without defining them in his source code.

Execution of a program using Static Libraries:

Static libraries are included in the source code by the programmer. When the source code is compiled the libraries are excluded since they are pre-compiled, and the object code is created. Later when the object code is built to a final executable file, the libraries are attached to the object code by a process called linking. The final executable file contains a copy of the library and the source code.

Advantages of using Static Libraries:

Static libraries are easy to implement. The programmer needs to just include the library in his source code. The programmer can save a lot of time avoiding writing the same code over and over again. He can always make it into a library file and use it for multiple programs.

Disadvantages of using Static Libraries:

During linking a copy of the appropriate library is attached to the object code. When multiple programs use the same library, the linker makes multiple copies of the same library. This takes up a lot of space in the memory.

The final executable file consists of the object code and all the libraries that are included in the program. This considerably increases the size of the executable file.

Programming using Dynamically Linked Libraries:

Dynamically Linked Libraries (DLLs) are similar to Static Libraries and contain a set of functions or procedures which are called from the source code. The difference is, during linking DLLs are not appended to the object code. Rather, they are referred to during the runtime. This can be done in two ways:

  • Load Time Binding – Under this method, Windows loads the DLLs when the application that uses them loads.
  • On Call Binding – The DLLs are not loaded even if the application that uses them loads. Instead, they are loaded when they are called by the application.

Advantages of using DLLs:

  • The libraries used by the program are not appended during linking. This reduces the size of the programmer and its memory requirement.
  • Programs run more efficiently due to the small size of the executable file.

Disadvantages of using DLLs:

The main disadvantage of using DLLs is that a DLL written in one language may not be accessible by a program written in another language even if both the programs call the same procedure in the same DLL.

Component Object Model:

Component Object Model (COM) is an architecture which allows applications and systems to be built from components supplied by different software vendors. COM provides a mechanism that allows binary software components supplied by different software vendors to connect and communicate with each other in a well-defined manner.

Features of COM:

Basic Interoperability of components: Components created by different vendors can connect and communicate with each other in a well -defined manner. This is achieved by defining a binary interface standard for method calling between components.

Versioning: COM allows one systems component to be updated without the need to update all other system components. This eliminates the need for version repositories or central management of component versions.

Language Independence: Components written by different vendors in different languages can be used together. This is because COM defines a binary object standard and not a source code standard. COM can be used to encapsulate OOP objects into components for widespread reuse, even with completely different programming languages.

Globally Unique IDs (GUID): COM uses 128 bit integers that are guaranteed to be unique in the world across apace and time, to identify every interface and every component object class. This ensures that components do not connect to the wrong component, method or interface even in networks of millions of computers.

Interfaces : Applications interact with each other and with the system through a collection of functions called interfaces. COM interfaces are strongly-typed contracts between components to provide a small but useful set of semantically related functions or procedures. COM defines one special interface called the IUnknown. All component objects are required to implement the IUnknown interface and all other interfaces derive from IUnknown.

Distributed Component Object Model (DCOM) :

DCOM extends COM to support communication among objects and components across different computers on a LAN, WAN, MAN or even the Internet. The existing COM architecture can easily be upgraded to DCOM architecture.

Features of DCOM :

Since DCOM is an extension of COM, all the characteristics of COM are applicable to DCOM. In addition to this, DCOM has other features like location independence, platform independence, connection management, improved security, fault tolerance, load balancing, protocol neutrality, etc..

Microsoft Transaction Server (MTS) :

MTS is a component based transaction processing system for building, deploying and administering Internet and Intranet server applications. MTS provides a graphical tools for this called the ‘MTS Explorer’ . MTS provides the following features;

  • The MTS runtime environment.
  • The MTS Explorer – A graphical tool for building deploying and managing applications.
  • Applications Programming Interfaces.
  • Resource dispensers – Services that manage non-durable shared state on behalf of the application components within a process.
  • Automatic Deployment Procedures.
  • MTS will work only on Microsoft Windows NT 4.0 and earlier versions. It is not supported in Windows 2000 and later versions.

Component Object Model+ (COM+):

All the best ideas in COM and MTS have been integrated into another runtime called COM+ by the introduction of MS Windows 2000. COM+ is a multi-tier system that replaces the traditional two tier systems. This is achieved by introducing a middle tier comprising of a set of business objects. Here the client applications consists of elements and codes for the user interface.

The need for COM+:

Some of the advantages of COM+ system, over a two tier system are listed below:

  • Clients applications have a hard time accessing data from multiple data sources. This usually happens when an applications needs to run business transactions using data that is spread across multiple computers.
  • When using the traditional two tier systems, things get exceptionally difficult if the data is stored in a variety of formats.
  • In two tier systems, users are restricted to specific platforms.
  • Two- tier systems cease to be operational when computers become disconnected.

.NET Platform:

.NET is Microsoft’s new software programming architecture which enables applications to work over the Internet. .NET allows a high level of software integration through the use of web services. The .NET platform revolves around the .NET Framework, which encompasses the actual language and execution platform, plus extensive class libraries providing rich built-in functionality. At its core, the .NET framework combines XML and SOAP to provide a new level of integration of software over the Internet.

The .NET Framework consists of two main parts: the common language runtime (CLR) and a unified, hierarchical class library. Applications compiled for .NET are not compiled directly to native code. Instead, they are compiled to an intermediate language called Microsoft Intermediate Language (MSIL). When an application is run for the first time, the common language runtime just-in-time compiler compiles the MSIL code into native code before it is executed. The common language runtime is more than a simple JIT compiler; it is also responsible for providing low-level execution services, such as garbage collection, exception handling, security services, and runtime type-safety checking.

The most unique attribute of .NET is its support for multiple languages. Currently, the supported languages include Visual C# .NET, Visual Basic .NET, the managed extensions for C++ and Visual J# .NET. Support for other languages like Perl, Python and COBOL are under development. This support for multiple languages is achieved due to a Common Language Specification (CLS). CLS describes the features that each language must provide in order to use the .NET framework and the Common Language Runtime and interoperate with components written in other programming languages. These features include the support for the same data types, usage of the same .NET framework classes, compilation of the source code to the same MSIL, and usage of the same CLR to manage execution. Languages that satisfy this specification is said to be .NET compliant.

Comparison of .NET and Java:

  • NET supports many languages like Visual Basic .NET, Visual J# .NET, Visual C# .NET, etc., unlike Java which is a single language on a single runtime environment. However, this multi-language support is merely a feature necessitated by the Microsoft framework of multiple languages.
  • Java is multi-platform. Because of this, the set of framework classes has traditionally been limited to what is available on all platforms. The .NET Framework is built upon the Windows platform. The classes offer the full scope of what is available on this platform.
  • The .NET Framework has a more robust versioning system than Java. In Java, if two versions of the same class are installed, the Java runtime will simply load the first class it finds on the class path, ignoring the version. In .NET, two or more different versions of the same class can be loaded and executed at the same time.