Smart Client Software Factory (SCSF) April 2008 for Visual Studio 2008 Released

After publishing an alpha version, a beta version and a RC 1 version I’m glad to announce that the final version of Smart Client Software Factory for Visual Studio 2008 has been published on MSDN.

What is new in this release?

How to enable a May 2007 solution

If you have a May 2007 solution and you want to enable it to use this new guidance please read this page.

Known Issues

In this page you will find the list of known issues that exists in Smart Client Software Factory - April 2008.

Downloads

Smart Client Software Factory - April 2008

Smart Client Software Factory Source Code - April 2008

Smart Client Software Factory Documentation - April 2008 (CHM format)

Documentation

Documentation on MSDN (HTML format)

Feedback

Feel free to give us your feedback on the discussion board. If you see issues, please post them to the Issue Tracker.

More Information of this release

For more information about this new release please read Blaine’s post and Michael’s post.

Enjoy this new guidance.

SCSF April 2008 Alpha for Visual Studio 2008 Just Published

Some time ago, I wrote a post about How to update the installer to run Smart Client Software Factory in Visual Studio 2008 Beta 2.

Now I’m proud to announce that we shipped an Alpha version of Smart Client Software Factory for Visual Studio 2008. As Blaine announced before, in order to run this new release you will require an upgrade of GAX/GAT to the February 2008 release.

scsfApril2008

For more information about this new release you can read the following posts:

Note: This is not the final release and still has known bugs. Use at your own risk

Download SCSF April 2008 Alpha Release and give us your feedback on the discussion board.

SCSF Sample Application and Demo Script published on Smart Client Contrib

logosc We have just published a new SCSF sample application on the Smart Client Contrib project. We have published also a demo script that provides step-by-step instructions to create a SCSF application. The goal of this demo script is to help presenters give a presentation that illustrates the main aspects of SCSF such as WorkItems, Commands, EventBroker, Services, Workspaces and the Dependency Injection pattern.

The application consists of two Business Modules:

  • Notifications module: this module populates the Main Menu Strip of the Shell with two items and adds them as invokers of the DumpWorkItem and ShowNews commands respectively. It also adds two views to the Shell.
  • Stocks module: this module shows BuyStock and Reports SmartParts in the the Shell.

The Shell is made up of two Workspaces: an OutlookBarWorkspace (the one in the right) and a DockPanelWorkspace (the one in the left). These workspaces are in the SCSF contrib project too.

SCSFLandingPageImage

Enjoy this new sample.

Download

Hello World with Microsoft Acropolis - Part Two: Services Dependencies

In my previous sample I showed how to create a Hello World sample using Microsoft Acropolis. Here we will modify that sample to use a service to retrieve the Hello World message.

  1. Download and open the previous sample. (AcropolisHelloWorld.zip).
  2. Add an interface called IMessageService.
  3. Add a class to implement the preceding interface. This class also has to inherit from the ServiceBase class and needs to be decorated with the [ServiceProduction] attribute. Name it MessageService.
      
  4. Open HelloWorldPart.xaml. In the User ConnectionPoints (Acropolis) tab, you will see your service interface, double click to add it as a service dependency. Notice the warning icon for the service dependency, which indicates that the dependency must be fulfilled before the part will be functional. 
  5. Rename the service dependency to MessageService.
  6. Open HelloWorldPart.cs (the HelloWorldPart.xaml code-behind) and modify the OnShowMessage method in order to use the service to retrieve the message
  7. Open Application.xaml. In the User Components (Acropolis) tab, you will see your service, double click to add it to fulfills the service dependency of the child HelloWorldPart. Notice that the warning icons have been replaced with check marks.
  8. Build and run the solution. Click on the triangle to see the list of commands. Select ShowMessageCommand.  

My idea was to finish the sample here, but I have received good feedback from Alex Bulankou (Microsoft Corporation), so I’m going to implement what he points me. We are going to change the way we display the message. Instead of using a WPF MessageBox, we are going to use the Acropolis UIService. Why? Alex explained me that this service is used by the Acropolis Framework to show our MessageBox whatever platform it’s running on. Now our MessageBox is platform-agnostic!.

  1. Open the HelloWorldPart.xaml. Double click over the IUIService Dependency in the Acropolis Framework tab to add a dependency to this service (same as we did in the step 4).
  2. Rename the service dependency to UIService.
     
  3. Open HelloWorldPart.cs (the HelloWorldPart.xaml code-behind) and modify the OnShowMessage method in order to use the UIService to retrieve the message.
     
  4. Build, run and enjoy!
      

Source code

  • You can get the source code of the Hello World sample by downloading the AcropolisHelloWorld-Part2.zip file below.
  • Important: The code is provided "as is" without warranty of any kind.

Attachment: AcropolisHelloWorld-Part2.zip

Hello World with Microsoft Acropolis - Part One

In this post I will show you how to create a simple Hello World Sample using Acropolis.

Acropolis is a set of components and tools that make it easier for developers to build and manage modular, business focused, client .NET applications, For more info, see Johnny’s post.

In order to do this sample, you will need to install the following components:

Let’s go!.

  1. Create a new Acropolis WPF Application. Name it AcropolisHelloWorld.
    acropolis1
  2. After creating the solution you will see the Acropolis Application Wizard. This wizard lets you choose the theme, the navigation style and the layout of the application. Navigate through the wizard, without changing the default values. Click on Finish to continue.
    acropolis2
  3. Now that you have created the solution, we will add an Acropolis Part and View. Right click over the project | New Item | Acropolis Part and View (WPF). Name it HelloWorldPart.xaml
    An "Acropolis" part is a coarse-grained piece of business logic that typically contains more functionality than a control, but less than an entire application. A part is different than a control because it contains only business logic and no user interface code. However, a part does have a user interface associated with it. The user interface portion of a part is called a part view or just view.
    acropolis3
  4. We are going to add a command to the HelloWorldPart. Open it and double click over the ComponentCommand of the Acropolis Framework tab of the ToolBox.
    The ComponentCommand is a connection point that enables parts or external entities to execute some piece of functionality inside a part.
    acropolis4
  5. If you follow all the steps, you are going to see this:
    acropolis5
  6. Rename the command to ShowMessageCommand. Add the CommandExecuted attribute with OnShowMessage as value.
      acropolis6
  7. Open HelloWorldPart.cs (the HelloWorldPart.xaml code-behind) and copy the following code:
      acropolis7
  8. Open Application.xaml. In the User Components (Acropolis) tab, you will see your part, double click to add it as a child part.
    acropolis8

    acropolis9

  9. Build and run the solution. Click on the triangle to see the list of commands. Select ShowMessageCommand and enjoy!

    acropolis10

    acropolis11

In the second part, we are going to learn how to retrieve the Hello World message from a service.

Source code

  • You can get the source code of the Hello World sample by downloading the AcropolisHelloWorld.zip file below.
  • Important: The code is provided "as is" without warranty of any kind.

Attachment: AcropolisHelloWorld.zip

How-to: Enable Smart Client Software Factory 2006 Solutions to use SCSF 2007

As you may know the version 2.0 of SCSF was shipped this weekend, so one of the main questions is how to get the existing SCSF June 2006 solutions running with this new version.

In order to do this, you have to follow this steps:

  1. Uninstall SCSF June 2006, because basically SCSF May 2007 is a replacement. SCSF May 2007 does not work side-by-side with SCSF June 2006. Don’t worry if you forget this step, because a nice warning window will advise you :)
    installError  
  2. Uninstall GAT and GAX in order to install the February 2007 CTP.
    Note: In order to unistall GAX, ensure you don’t have any package registered, otherwise the uninstallation will fail:
    gaxError
  3. (Optional) Read Tom Hollander’s post, to know how to get all the factories running with this new version of GAX/GAT.
  4. Install SCSF May 2007. Check dependencies before install it to make sure you have all the prerequisites installed.
    install
  5. Copy the following assemblies from the Lib folder of the SCSF installation directory (%programfiles%\Microsoft Smart Client Factory\Lib\) to the Lib folder of your solution:
    • Microsoft.Practices.CompositeUI.dll
    • Microsoft.Practices.CompositeUI.WinForms.dll
    • Microsoft.Practices.CompositeUI.WPF.dll
    • Microsoft.Practices.EnterpriseLibary.Common.dll
    • Microsoft.Practices.EnterpriseLibary.Data.dll
    • Microsoft.Practices.EnterpriseLibary.Data.SqlCe.dll
    • Microsoft.Practices.EnterpriseLibary.ExceptionHandling.dll
    • Microsoft.Practices.EnterpriseLibary.ExceptionHandling.Logging.dll
    • Microsoft.Practices.EnterpriseLibary.Logging.dll
    • Microsoft.Practices.ObjectBuilder.dll
    • Microsoft.Practices.SmartClient.ConnectionMonitor.dll
    • Microsoft.Practices.SmartClient.DisconnectedAgent.dll
    • Microsoft.Practices.SmartClient.EndpointCatalog.dll ordersManager
    • Microsoft.Practices.SmartClient.EnterpriseLibrary.dll
  6. Open the solution in Visual Studio. If you have the June 2006 guidance package enabled in the solution, a dialog box appears that asks if you want to remove it. Click Yes to remove it.
  7. On the Tools menu, click Guidance Package Manager. The Guidance Package Manager window will appear.
  8. Click Enable / Disable Packages.
  9. From the list of packages, select Smart Client Development May 2007, and then click OK. The Guidance Package Manager will enable the guidance package.
  10. Click Close to close the Guidance Package Manager.

Presentation1

Enjoy the new version, and if you have any doubt please visit the SCSF Forum to get all the answers.

Smart Client Software Factory: Registering and Retrieving Services

In this post I will try to sketch an explanation about different ways of registering and retrieving services in SCSF / CAB.

SCSF Services


How To: Registering Services

We have two ways of implementing the service registration.

  • Using the [Service] attribute 

    This attribute indicates that a class should be automatically registered as a service into the application's root WorkItem

    Usage:

    public interface IMyService
    {
        
    int GetSomeData();
    }

    [Service(typeof(IMyService))]
    public class MyService : IMyService
    {
        
    public int GetSomeData()
        {
            
    return 1;
        
    }
    }

    With this code CAB creates an instance of this class and registers it as service during application startup. The constructor parameter tells CAB the interface key to use for the registration of the service (for location purposes).

  • Using WorkItem.Services.Add()

    If you want to register a service programmatically, you have to call the Add or the AddNew method of the services collection of the WorkItem within you want to use the service.

    Usage:

    RootWorkItem.Services.Add(myServiceInstance);

    RootWorkItem.Services.AddNew();
    RootWorkItem.Services.AddNew();

    How To: Retrieving Services

    Now that we have registered our services, we will want to know how to retrieve them. Let's see the two ways of doing that.

    • Using the [ServiceDependency] attribute

      This attribute indicates that property or parameter is a dependency on a service and should be injected when the object is added to a WorkItem.

      Usage:

      private IMyService myService;

      [ServiceDependency]
      public IMyService MyService
      {
          
      set { myService = value; }
      }

      With this code, we are telling CAB that we are having a dependency on the IMyService that has already been created and is available to use. For this purpose CAB uses Inversion of Control (IOC) / Dependency Injection (DI).
      So when the object is added to the Workitem, the property will be automagically injected with the correct service instance.

    • Using WorkItem.Services.Get()

    This way is more “on-demand” than ServiceDependency.

    Imagine that we have a second service AnotherService which implements IAnotherService interface and have the Service Attribute.

    In our view, we are not going to have a property with the service, so we are not going to apply the ServiceDependency attribute.

    Usage: (for example in a method)

    public void MyMethod()
    {
        IAnotherService mySecondService 
    rootWorkItem.Services.Get();
        
        
    // …
    }

    When you use the ServiceDependency attribute, CAB is calling Services.GET behind the scenes.

    I hope people having doubts about services in SCSF/CAB find this post useful.