The .NET Framework allows any COM+ component to be accessible through a SOAP service. Using the Component Services Microsoft Management Console (MMC) snapin you can configure the COM+ component in such a way that the interface will be available as a SOAP service. Microsoft Internet Information Services (IIS) will be used to host the service. Notice the use of the term SOAP service. The service uses SOAP over Hypertext Transfer Protocol (HTTP), but the SOAP spoken here is that of .NET Remoting. You ll need the soapsuds command-line utility to create a .NET remoting proxy for this service.

The last service offered through Enterprise Services is synchronization. When you use synchronization, COM+ creates a proxy for you that runs all instances of your object in its context. COM+ marshals all calls across this proxy where a performance penalty occurs. The service guarantees that only one thread is available to run each object at a time. COM+ synchronization provides another easy way to provide synchronization, but be careful when using it. Many calls to a COM+ synchronized object degrade your application greatly because of all the marshaling across the proxy. Be sure to test responsiveness when using it.

Using Barcode maker for iPhone Control to generate, create QR Code ISO/IEC18004 image in iPhone applications.

www.OnBarcode.com

You create a serviced component by implementing a .NET Framework class that inherits, directly or indirectly, from the System.EnterpriseServices.ServicedComponent class. Serviced component classes are hosted in a COM+ application and can use COM+ services by using the System.EnterpriseServices namespace. To access the System.Enter priseServices namespace you have to add an assembly reference to System.EnterpriseServices.dll, which is part of the .NET Framework Class Library.

Using Barcode generation for Visual Studio .NET Control to generate, create barcode image in .NET applications.

www.OnBarcode.com

Public Class OrderService Inherits ServicedComponent End Class //C#

using System.EnterpriseServices;

namespace MSLearning.12.Services

public class OrderService : ServicedComponent

Adding a Default Constructor

For COM+ to be able to manage your component, it needs to be able to create an instance of your class. COM+ will not be able to provide any default parameters when creating your class, so you need to implement a default public constructor.

'VB Imports System.EnterpriseServices Public Class OrderService

12

Creating Serviced Components

Inherits ServicedComponent ''' <summary>

''' Default constructor is required for COM+ registration.

''' </summary>

''' <remarks></remarks>

Public Sub OrderService() End Sub End Class //C# using System.EnterpriseServices;

Types in your managed code assembly are by default not visible to COM+. This is because your assembly info file contains the following entry:

'VB Imports System.Runtime.InteropServices

' Setting ComVisible to false makes the types in this assembly not visible

' to COM components. If you need to access a type in this assembly from

' COM, set the ComVisible attribute to true on that type.

<Assembly: ComVisible(False)>

//C# using System.Runtime.InteropServices;

// Setting ComVisible to false makes the types in this assembly not visible

// to COM components. If you need to access a type in this assembly from

// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

You need to select Show All Files in Solution Explorer to be able to see the assemblyinfo in Visual Basic.

Lesson 1: Serviced Component Overview

It is considered poor design to make all your types visible to the COM+ environment. To make your custom type visible to COM+ you need to add the ComVisibleAttribute to your class. The ComVisibleAttribute can be found in the System.Runtime.InteropServices namespace.

In COM+ you can choose between the following two types of application activation:

Library

A library application runs in the process of the client that creates it and can be called only by clients located on the same computer. This is the default setting. Server applications run in their own dedicated server process.

Server

12

Creating Serviced Components

It is possible to specify whether components in the assembly run in the creator s pro cess or in a system process using the ApplicationActivationAttribute in the Assemblyinfo.cs file: