Tuesday, May 29, 2007

Stage 2: Creating and Loading the Module

  1. Add new Class Library project named MyModule to the existing solution
  2. In Properties->Build->Output select \bin\Debug folder of ShellApplication project
  3. Save and reopen then, Properties->Outputpath to ..\ShellApplication\bin\Debug
  4. Add Reference
    Microsoft.Practices.CompositeUI.dll
    Microsoft.Practices.CompositeUI.WinForms.dll
    Microsoft.Practices.ObjectBuilder.dll
  5. Create a class named MyWorkItem.cs derived from WorItem and include namespace
    using Microsoft.Practices.CompositeUI;
    public class MyWorkItem : WorkItem
    {
    }
  6. Add a module Initialiser

    1. add class named MyModuleInit.cs derived from ModuleInit and include namespaces

      using Microsoft.Practices.CompositeUI;
      using Microsoft.Practices.CompositeUI.Services;
      using System.Windows.Forms;

      public class MyModuleInit : ModuleInit
      {
      }

    2. Add the following variable to reference the WorkItemTypeCatalogService so that you can access it to register your WorkItem:

      private IWorkItemTypeCatalogService myCatalogService;
      [ServiceDependency]
      public IWorkItemTypeCatalogService myWorkItemCatalog
      {
      set { myCatalogService = value; }
      }

    3. Override the Load method of the ModuleInit class so that it registers your module's WorkItem.

      public override void Load()
      {
      base.Load();
      myCatalogService.RegisterWorkItem<MyWorkItem>();
      }

    4. instruct the CAB to load the new module in ProfileCatalog.xml.
<?xml version="1.0" encoding="utf-8" ?>
<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile">
<Modules>
<ModuleInfo AssemblyFile="MyModule.dll" />
</Modules>
</SolutionProfile>


right-click the file ProfileCatalog.xml and click Properties. Change the Copy To Output Directory property to Copy Always.

No comments: