Telerik blogs

The Microsoft Composite UI Application Block (CAB) is a framework used for creating Model-View-Presenter style windows forms applications. The Smart Client Software Factory (SCSF) streamlines the process of creating these applications by providing us with a powerful base project and a set of menu options for quickly generating modules, views, and events in Visual Studio. Unfortunately, CAB only provides direct support for the common windows components included with Visual Studio. It is possible to develop your own support for third party components, but this can be a confusing and time consuming process. Lucky for us, Telerik noticed that there was a need for CAB support with it’s own controls. This resulted in the release of the Telerik CAB Enabling Kit (TCEK).

In addition to the product downloads page, the Telerik CAB Enabling Kit is available for download from CodePlex and includes the things we will need to get started with this tutorial. This blog post assumes you have a basic knowledge of CAB and have worked with it before. If you have not worked with CAB before, here are a few resources I recommend reading to help you get started. Once you have explored these resources, feel free to come back here and read the rest of this post.

White Paper - Designing Smart Clients Based on CAB and SCSF - This white paper contains an abundance of information about everything supported by CAB. It can be a little hard to grasp all of the concepts it describes, so don’t worry if you have a little trouble, eventually it will come to you.

Rich Newman's Introduction to CAB/SCSF - After working with CAB for over a year, I still had several unanswered questions about why certain things work the way they do. This guide cleared up several of those questions for me.

That being said, I would like to get you started with the TCEK through a series of blog posts I will be making over the next few weeks. Learning any technology can be a little confusing, especially CAB, so I hope this makes the process a little easier for you. Lets get started!

Tutorial Description and Purpose

This tutorial will explain the setup process for a CAB project based on the TCEK. This setup is required for using the Telerik WinForms components with CAB specific functionality such as Commands and UIExtensionSites.

My CAB/Visual Studio Configuration

My CAB setup is as follows. If you notice any discrepancies between your setup and the way I’ve written this tutorial, you may be using different versions of these tools/libraries.

Visual Studio 2008 SP1
Microsoft Enterprise Library 4.1 - October 2008
Microsoft Guidance Automation Extensions - February 2008
Composite UI Application Block - December 2005
Smart Client Software Factory - April 2008
RadControls for WinForms - 2009.2.729
TCEK Cab Installation Package - 2009.2.701

Creating the Project

In this section, you will learn how to add the TCEK project to a newly created Smart Client Application.

  1. Download the Telerik CAB Enabling Kit
    1. The TCEK is available on Code Plex.
    2. Extract the contents of the kit somewhere memorable
  2. Start up Visual Studio.
  3. Create a new Smart Client Application (C#)
    1. In the menu, select File->New->Project
    2. Under project types, expand “Guidance Packages,” then select “Smart Client Development - April 2008”
    3. Under templates, select “Smart Client Application (C#)”
    4. Name the project “CABExample1”
    5. Click OK
      Creating the project   
      Figure 1. Creating the project
    6. In the dialog that appears, click Finish.
    7. Sit back and relax while your project is generated.
  4. Add the TCEK to your solution
    1. From the extracted TCEK, copy “…\Telerik CAB Enabling Kit Q2 2009\Source\Telerik.CAB.WinForms\” to your project directory. 
      CopyCabKit
      Figure 2. Copying the TCEK to your project directory
    2. In Visual Studio, right click on the “Source” folder in the Solution Explorer. In the context menu, select Add->Existing Project 
    3. Browse to the Telerik.CAB.WinForms folder in your project directory and open “Telerik.CAB.WinForms.csproj”.
      AddedToProject
      Figure 3. Adding the TCEK project to your solution
  5. Test the project by compiling and running it.

 Note: I ran into a slight problem here most likely based on my system’s configuration. When running the program, I received a ModuleLoadException claiming that Infrastructure.Layout.dll was not found. This problem is easily fixed by modifying profilecatalog.xml. My project’s assembly files were improperly referenced here for some reason. Changing the references Infrastructure.Layout.dll, and Infrastructure.Module.dll to CABExample1.Infrastructure.Layout.dll and CABExample1.Infrastructure.Module.dll respectively solved the problem.

Configuring the Project

Once the project is created, you will need to complete a few steps to convert it into a TCEK based CAB Application.

  1. Add references from each of the CAB generated projects to the “Telerik.CAB.WinForms” project.
    1. Right click on the Shell project.
    2. Select Add Reference…
    3. Select the Projects tab.
    4. Select the “Telerik.CAB.WinForms” project.
    5. Click OK.
      AddingReferences
      Figure 4. Adding references to the TCEK project
    6. Repeat the previous steps to add references to the rest of the CAB generated projects.
  2. Update the CAB DLL references in the “Telerik.CAB.WinForms” project.
    The CAB DLLs referenced by the Telerik.CAB.WinForms project may be different versions than referenced by your CAB projects. It is important to update them to avoid possible compilation errors and other issues in the future.
    1. Expand the “Telerik.CAB.WinForms” project.
    2. Select the references to “Microsoft.Practices.CompositeUI,” “Microsoft.Practices.CompositeUI.WinForms,” and “Microsoft.Practices.ObjectBuilder.“
    3. Right click the selected references and click Remove.
    4. Right click the References folder and select Add Reference…
    5. Select the Browse tab.
    6. Browse to “…/CABExample1/Lib “
    7. Select the three DLLs you just removed from the project and click OK.
      ReaddingReferences
      Figure 5. Updating the CAB DLL references
  3. Expand the Infrastructure.Library project
    1. Open the “SmartClientApplication.cs” file.
    2. In the class declaration, replace the original version of the code with the TCEK version.
      // Original Version
      public abstract class SmartClientApplication<TWorkItem, TShell> : FormShellApplication<TWorkItem, TShell>
       
      // TCEK Version
      public abstract class SmartClientApplication<TWorkItem, TShell> : RadFormShellApplication<TWorkItem, TShell>
    3. Compile and run the application.
    Your CAB application is now fully integrated with the TCEK. Pretty simple eh? Just remember, when you start creating modules to include with your project, you will need to reference the Telerik.CAB.WinForms project. In my next post, I will go over the usage of the UIExtensionSite functionality provided by the TCEK.

Click here to download the source code used in this post.


Comments

Comments are disabled in preview mode.