Introduction

Reusing is
a common requirement in any team or framework. However, we usually reuse at
business logic or general infrastructure level. The User Interface reuse is
more difficult to achieve. CAB architecture is loosely coupled enough to make
that possible.

The
following screenshots illustrates the bank teller quickstart application hosted
in Outlook, Word and a regular Winforms application.

Just two
lines of code [:)]

 

ho1 ho2

ho3 ho4

 

Instructions:

  1. Download the solution
  2. Extract
    the solution and build it. If you experience problems, check that
    the references to the CAB assemblies are correct.

Create
the shell and the CAB application

  1. Create a
    new project to host the shell and the CAB application.

    The shell in a regular CAB application would be a Form. However if we
    want to host the application in a different executable (Outlook, Word, IE,
    etc), we already have the container. So the Shell will be a UserControl
    .

  2. Add
    references to CAB assemblies.
  3. Create a
    regular UserControl and place the workspaces, menus, toolstrip, statusbar,
    and everything related to the shell.
  4. If you
    need to override the CAB events like AfterShellCreated or
    AddBuilderStrategies, create a new class that derives from
    CompositeUIExtensions.Hosting.UserControlShellApplication

    where TUserControlShell is the type of the UserControl created on the previous step
    and
    TWorkItem is the root work item that
    must derives from
    UserControlWorkItem.

Consume
a CAB module/app from Outlook/Word/External application

  1. Open your
    project and add references to
    CompositeUIExtensions.Hosting and the CAB assemblies. Also
    copy the project related assemblies (module assemblies for example) to the
    application output directory.
  2. Creates
    an instance of
    CompositeUIExtensions.Hosting.UserControlHost and add it to the
    correspondent Controls collection. The following code illustrates how;

UserControlHost plugin = 	new UserControlHost();…Controls.Add( plugin );

  1. Create

    the ProfileCatalog.xml, configure it with the desired module/s and set the

    Build Action to CopyAlways. 

Download

the solution
that shows how to host the BankTeller app inside Outlook, Word and

Winforms.

5 Responses to “HowTo: Host a CAB application in Outlook, Word, Excel, or a common Winforms application”

  1. http:// Says:

    I was unable to “Download the solution” that shows how to host the BankTeller app inside Outlook, Word, and Winforms.

    Thanks for paving the way.

  2. http:// Says:

    Hi John,
    I’ve just tried the download and it worked. You got any http error?

    Matias

  3. http:// Says:

    The Cab Solution link doesn’t respond.
    If I chose Save Target As, I get “My current security settings don’t allow it”

    But the Hosting Cab at the top of the page does work. If chose “Save As” on that, it works also.

    If I use Properties on the hyperlinks, both links show Hosting Cab.zip on the content\binary. The properties appear to link to the same file.

    Perhaps this is a cross-domain issue.

  4. http:// Says:

    Hi Matias,
    The Cab solution download link does not work.
    it points to the following url:

    http:///www.southworks.net/matiaswoloski/content/binary/Hosting%20CAB.zip

    as you see, there are three “///” that follow “http:”
    if I remove one “/”, it points to the same url of CompositeUIExtensions.Hosting download link.
    so could you please let me know the url to download the solution.

    Thanks,

    g

  5. matiaswoloski Says:

    Everyone,
    I’ve corrected the url. Both links were pointing to the same url on purpose. You can download the whole solution and if you want to use it in your app follow the instructions.

    Thanks
    Matias

Leave a Reply