- Part 4
Creating and Accessing a Serviced Component and Using Message Queuing
- Topic 1
- Create a serviced component.
- Add attributes to a serviced component.
- Register a serviced component.
- Implement security.
- Add a reference to a serviced component in an application.
- Create an instance of a serviced component.
- Call the methods of a serviced component.
A serviced component is a .Net class that can use COM+ services including transactions and Message Queueing through declarative configuration.
To create a service component you must inherit from the ServicedComponent class. After that you need only add the required attributes to take advantage of COM+ services. Such attributes include:
- ApplicationAccessControlAttribute – specifies access control to an assembly containing ServiceComponent Classes
- ApplicationActivationAttribute - Specifies whether components in the assembly run in the creator's process or in a system process.
- ApplicationIDAttribute - Specifies the application ID (as a GUID) for this assembly.
- ApplicationNameAttribute - Specifies the name of the COM+ application to be used for the install of the components in the assembly.
- ApplicationQueuingAttribute - Enables queuing support for the marked assembly and enables the application to read method calls from Message Queuing queues.
- AutoCompleteAttribute - Marks the attributed method as an AutoComplete object.
- ComponentAccessControlAttribute - Enables security checking on calls to a component.
- COMTIIntrinsicsAttribute - Enables you to pass context properties from the COM Transaction Integrator (COMTI) into the COM+ context.
- ConstructionEnabledAttribute - Enables COM+ object construction support.
- DescriptionAttribute - Sets the description on an assembly (application), component, method, or interface.
- EventClassAttribute - Marks the attributed class as an event class.
- EventTrackingEnabledAttribute - Enables event tracking for a component
- ExceptionClassAttribute - Sets the queuing exception class for the queued class.
- IISIntrinsicsAttribute - Enables access to ASP intrinsic values from ContextUtil.GetNamedProperty.
- InterfaceQueuingAttribute - Enables queuing support for the marked interface.
- JustInTimeActivationAttribute - Turns just-in-time (JIT) activation on or off.
- LoadBalancingSupportedAttribute - Determines whether the component participates in load balancing, if the component load balancing service is installed and enabled on the server.
- MustRunInClientContextAttribute - Forces the attributed object to be created in the context of the creator, if possible.
- ObjectPoolingAttribute - Enables and configures object pooling for a component.
- PrivateComponentAttribute - Identifies a component as a private component that is only seen and activated by components in the same application.
- SecureMethodAttribute - Ensures that the infrastructure calls through an interface for a method or for each method in a class when using the security service. Classes need to use interfaces to use security services.
- SecurityRoleAttribute - Configures a role for an application or component.
- SynchronizationAttribute - Sets the synchronization value of the component.
- TransactionAttribute - Specifies the type of transaction that is available to the attributed object. Permissible values are members of the TransactionOption enumeration.
Pay careful attention to the ApplicationAccessControl, ComponentAccessControl and SecurityRole Attributes when dealing with COM security.
To register a serviced component you must compile the component with a strong name, register it into the windows registry and configure the component in the COM catalog.
Use the regsvcs.exe tool to manually register an assembly that contains service components.
The tool will do the following:
- Load the Assembly
- Register the Assembly
- Generates a Type Library
- Calls the LoadTypeLibrary Method to register the library
- Installs the type library into the requested application
- Configures the classes
Alternatively you can use dynamic registration by simply copying the assembly to the bin directory of the COM+ application.
To use the serviced component, ensure that you have the proper references and simply create an instance of the object and use it. Any COM+ attributes that are applied to the object or methods will ensure that the contexts of the instances are hosted in COM+.
Other Resources & Links:
Writing Service Components
How to: Create a Serviced Component
Registering Serviced Components
COM+ Role-Based Security and the .NET Framework