How to: Create a Foundational Module

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.

Foundational modules are units of development and deployment that encapsulate infrastructure services. They do not contain Web pages nor do they have a module composition container. An example of a foundational module could be a module that contains services, such as logging and authorization services.

This topic describes how to use the Add Foundational Module Template to generate a foundational module.

Prerequisites

The Add Foundational Module recipe assumes that you have an existing Web client solution. For information about how to create a Web client solution, see How to: Create a Web Client Solution.

The Add Foundational Module****recipe applies to the Visual Studio solution folder (typically, this is the Modules solution folder).

Steps

The following procedure describes how to use the recipe to create a foundational module.

To use the Add Functional Module recipe to create a foundational module

  1. In Solution Explorer, right-click a solution folder, point to Web Client Factory, and then click Add Foundational Module (C#) or Add Foundational Module (Visual Basic), as shown in Figure 1.

    Ff709811.b15c417d-5c59-4073-997b-fde38ee338ef(en-us,PandP.10).png

    Figure 11

    The Add Foundational Module recipe menu

  2. (Optional) In the Add New Project dialog box, illustrated in Figure 2, change the name of the project in the Name box and the location of the project in the Location box.

    Ff709811.19f36bab-aa7a-4155-adce-27c8154447f9(en-us,PandP.10).png

    Figure 12

    The Add Foundational Module project template

  3. Click OK. The recipe starts the Add Foundational Module Wizard. Figure 3 illustrates the first page of the wizard.

    Ff709811.c1190861-0bca-4534-8d24-48a189b5018e(en-us,PandP.10).png

    Figure 13

    The Add Foundational Module recipe wizard

  4. Under Web site in the left pane, click the Web site with a Web.config file that is to be used to define the module.

  5. (Optional) If you want to create a separate project that contains the public interface for the module, select the Create an interface library for this module check box. By using a separate project for the public interface of the module, you reduce the coupling between the business module and other modules in the application because modules reference the interface project instead of the module assembly.

  6. (Optional) If you want a test project for the module to be created with test classes for your module components, select the Create project for unit tests check box.

  7. Click Finish. The recipe generates the foundational module.

Outcome

As illustrated in Figure 4, you will have the following elements in your solution:

  • A C# class library project. This is the module class library. It contains a module initialization class and an empty folder named Services.
  • (Optional) A class library project that contains the public interface. This is a project that you can use to define the public interface that you want to share with other modules.
  • (Optional) A test project for the module. This is an empty project that you can use to create your unit tests.
  • An updated Web.config file. The module definition will be added to the <modules> section of the Web.config file of the selected Web site. The Composite Web Application Block uses this information to load the module when the application starts.

Ff709811.34459a04-7f9f-46c0-bbb7-26dd739f5a6f(en-us,PandP.10).png

Figure 14

Web Client Solution with a foundational module Module1

Next Steps

After you run the Add Foundational Module recipe, you are ready to perform one of the following steps:

  • Implement services. Services are components that provide application or infrastructure logic.
  • Registers the services as global services. To register global services, you add them to the root composition container. For more information related to registering and using services, see How to: Register and Use Services.