Creating Custom Services

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
To create client business applications using current Microsoft technologies, see patterns & practices' Prism.

Typically, you will want to create custom services in your Composite UI Application Block applications to provide functionality for the views and controllers. You can create a service by adding a class to a module or the shell, and then applying the Service attribute to the class definition.

To create a service

  1. Add a new interface to an appropriate module.

  2. Add members that the interface will define.

  3. Add a new class to the module or the shell.

  4. Inherit from the interface and add the required functionality to the members.

  5. Add the Service attribute to the class definition, as shown in the following code.

    [Service(Type=typeof(IMyService))]
    public class MyService : IMyService
    
    'Usage
    <Service(Type:=GetType(IMyService))> _
    Public Class MyService 
      Implements IMyService
    

The Service attribute triggers the creation of the service when a module is loaded. Service registration occurs by using the type specified in the Type property. You can also add services to a WorkItem programmatically, as explained in the section Adding Services earlier in this document. You can then use the functionality in the application by getting a reference to the service and calling its methods.