Pages

Friday, January 11, 2008

COM+ Components

COM+ is a programming model based on Component Object Model (COM). COM+ does not replace the COM. In fact, COM+ technology uses the COM by extending its features to provide enterprise level services.

COM was the very first methodologies to facilitate object oriented software implementation. It is mainly used to encapsulate business task and logic into one business object, called COM component in the distributed environment which can be shared and accessed by different applications.

In the real world scenario, more than one COM component work altogether to achieve a high density task. To manage the integrity and security among different components, COM uses another service of Microsoft, called Microsoft Transaction Server (MTS).

In other words, COM+ is nothing but a combination of both COM and MTS. It means COM+ = COM + MTS. COM+ was first introduced in Microsoft Windows 2000 Server. COM+ also includes additional features like object pooling, load balancing, component queuing, etc. These services were being known as the COM+ Component Services. When multiple components are grouped together it is referred to as COM+ applications.

COM+ Component Service using .NET

Microsoft Visual Studio has come up with the libraries and classes through which we can create, install and consume COM components. In fact, .NET has been designed to offer COM+ services through these and becomes easier. Once COM+ component is installed correctly it can be used by a variety of applications (including web applications), and these applications are termed as clients of the COM+ application. Components developed in .NET are called managed components.

Building a managed assembly in VB 2005 for COM+ Service

Building a managed component is nothing but developing an assembly using VS 2005 "Class Library" project. After getting the error free DLL, we will setup it to make it accessible in COM+ environment. Let us proceed for building the managed component step-by-step. I have used VB 2005 for this example.

Create a library project to build a valid serviced component assembly

Open Visual Studio 2005 IDE. Create a class project as:

File >> New >> Projects

Choose Visual Basic as in Project Types and "Class Library" in project templates.

Give the project name as COMPlusObject and click OK.

It will create the COMPlusObject project containing a default class Class1.vb. Rename this class to COMService.vb.

In this we need to import System.EnterpriseServices namespace and before doing it add a reference of System.EnterpriseServices in the project.

Project >> Add Reference >> .NET >> Choose System.EnterpriseServices >>

it is the time to setup this assembly in COM+ context. To achieve we need to do two things.

1. Install the assembly in Global Assembly Cache (GAC).

2. Install the assembly in Component Services list to run as the COM component.

Install the assembly in GAC

If you want to place the assembly in a shared location GAC then you can follow following steps.

Step 1: Open the Visual Studio 2005 Command Prompt and go to the bin directory of project.

C: \COMPlusObject\COMPlusObject\bin>

Step 2: Execute the following command to install the assembly in GAC.

C: \COMPlusObject\COMPlusObject\bin> gacutil /i Release/COMPlusObject.dll

No comments: