COM+ component services

Please let other users know how useful this tip is by rating it below. Do you have a tip or code of your own you'd like to share? Submit it here.

Classes written using the Microsoft .NET Framework can make use of COM+ services in an integrated and logical manner. This article discusses COM+ services for in-process components such as JIT, synchronization, transactions, object pooling, constructor strings and the shared property group manager.

Today, developers use such tools as Microsoft Visual Studio 6.0 to build COM+ components and install the components in COM+ applications to use COM+ services. With Visual Studio.NET, managed classes are built and then installed in COM+ applications, in order to get such COM+ services as transactions, object pooling and activity semantics. Using Visual Studio.NET and the .NET Framework provides a number of advantages over Visual Studio 6.0 -- namely, better tools, the common language runtime and a much easier coding syntax. Each managed class can be hosted in a coexisting COM+ context; thus, managed classes can take full advantage of all the COM+ services. In the .NET Framework, these classes are known as serviced components. Any managed class can be modified to use COM+ services. The Microsoft.ComServices namespace provides various custom attributes and classes to assist the developer in accessing these services from managed code.

Creating BankComponent.cs

using System;
using System.EnterprizeServices;
using System.Runtime.CompilerServices;
[assembly: ApplicationName("BankComponent")]
[assembly: AssemblyKeyFileAttribute("TestApp.snk")]
public class Account : ServicedComponent
// SetComplete automatically called if no exception
public bool Post(int accountNum, double amount)
// .. update the database, no need to call SetComplete
return true;
// - Registration details -
// COM+ Application Name to add the Component

// Strong Name for Assembly


Creating BankConsoleClient.cs

using System;
using BankComponent;
namespace BankComponentConsoleClient
class Client
public static int Main()
Account act = new Account();
act.Post(5, 100);
return 0;

Compile the files with the following procedure

SN –k TestApp.snk
csc /target:library /r:Microsoft.ComServices.Dll BankComponent.cs
csc /target:exe /r:BankComponent.Dll BankConsoleClient.cs

When you invoke the BankConsoleClient.exe, the COM+ application gets generated. Now the component is ready to use the services of COM+ runtime and can be accessed using VB6.

Figure 1

This was first published in June 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.