All posts by Ezequiel Sculli

Book: Programming Microsoft ASP.NET 2.0: Core Reference

During the last 2 months, I spent my travel time from and to my home reading the book mentioned in the title. When I told this to Matias, he asked me if I was crazy because it is a big book (700 pages) and width like a bible.

I have taken it from the Southworks’ Library and read it because, although I have 2 years of experience developing on this platform, there are some things and tools to use to make your Web application in a better way on ASP.NET that I haven’t known until now. And also, I think this will be very useful for my actual job inside UX Patterns & Practices (Sustained Engineering) team giving a better support to the community in the Web Client Software Factory (WCSF) forum.

My opinion about the book

This is a great book. A good way to consume it is reading all the content one time to get knowledge about what the book talks and make a refresh of the concepts in your mind. And then, keeping it in your library as a reference to check it if you have doubts about a particular topic or what is the best way or practices to implement something on ASP.NET.

The different Chapters of the Book

The book contains 14 chapters going through different topics, some very basic like the following:

  • What is ASP.NET & Web Development in VS (Chapters 1 & 2)
  • How Pages are structured and how you can working with these (Chapters 3 & 5)
  • ASP.NET Controls (HTML & Web Controls) and UI Elements (Chapters 4 & 6)
  • ADO.NET (Chapters 7 & 8 )

And another more interesting and useful in my opinion:

  • The Data-Binding Model and how it is performed in ASP.NET (Chapter 9)
  • The different objects that compose the HTTP Request Context (Chapter 12)
  • The different ways to save data in your Web application using the Session, the Cache and/or the ViewState (Chapters 13 & 14)
  • The different ways to authenticate the User of your application, the Membership and Role Management APIs and the security web controls (Chapter 15)

Next Steps

As you may know, this year will be released the ASP.NET 4.0 version. So, this book is quite old but I keep my opinion about it, it is a good book. The idea is to continue reading books, articles and blog posts about what new features have the newer versions incrementing the knowledge that I get from this read book.


SCSF Solution file is checked out from TFS when it is opened in Visual Studio 2008 SP1

The UX Patterns & Practices (Sustained Engineering) team was working on a task trying to find the causes why the solution file of an SCSF Solution is checked out from Team Foundational Server (TFS) when it is opened in Visual Studio 2008 SP1. We found that the issue appears when some properties are added to the GlobalSection(ExtensibilityGlobals) section inside the Solution file. So we created a workaround that saves the properties that cause the automatic checked out in other file than the solution file, an XML file.

Note: This issue was investigated based in a customer’s problem who uses TFS as Source Control, but it is possible that the issue appears when the solution is binded to other Source Control for the same reason. Also, the provided workaround should work in your case too.

Cause of the Issue

As I said, we detected that the issue appears when some properties are added to the GlobalSection(ExtensibilityGlobals) section inside the Solution file. After trying to find the cause in different environments (with different configurations among Visual Studio 2008 SP1, GAX & SCSF), we arrived to the conclusion that the issue is not related neither to GAX nor SCSF, and may be related directly to Visual Studio (because the issue also appears without GAX & SCSF).This issue appears when creating a SCSF solution, because the GP happens to store some properties in this section, but the checkout when opening the solution everytime is not caused by SCSF itself.


To avoid using the problematic section in the solution file, we created a custom SCSF Guidance Package that saves the content of this section in a separated XML file. In this way, the Visual Studio does not get knowledge about these properties avoiding the check out.


Here you can find some stuff that you should use to fix the Guidance Package with the Workaround, or, if you prefer, you can download directly the fixed Guidance Package or an installer:

Disclaimer: The code is provided “AS IS” with no warranties, and confers no rights.
Note: The Visual Studio 2008 SP1’s fixes was provided by Mariano Converti, you can find more information about these in his post.

Steps to update the Guidance Package

To perform these steps you should download the SCSF GP (fix for TFS) – Modified file from the Downloads section and install GAT 2008.

  1. Open the SCSF Guidance Package.
  2. Create a new Global Value Provider class named XmlGlobalValueProvider. Located it in SmartClientFactoryPackageValueProviders folder of the Guidance Package solution. The code for this class can be found in the downloaded zip file.
  3. Update SetGlobalValueAction class to use XML file. The class is located in the SmartClientFactoryPackageActions folder of the Guidance Package solution. The code for this class can be found in the downloaded zip file.
  4. Update all references to “Microsoft.Practices.RecipeFramework.Library.ValueProviders.GlobalValueProvider, Microsoft.Practices.RecipeFramework.Library”. They should now reference Microsoft.Practices.SmartClientFactory.ValueProviders.XmlGlobalValueProvider. This can be done by using Quick Replace.
  5. Update ViewTemplateReferenceCS and ViewTemplateReferenceVB classes, so they get the CommonProjectGuid from the xml file. The code for this classes can be found in the downloaded zip file.
  6. Important: If you use this without the fix for VS2008 SP1, you will need to replace this line:
              if (reference.Name == referenceIdentity) return true;
    in both classes for this one:
              if (reference.Identity == referenceIdentity) return true;

  7. Open the RecipesCommonCreateSmartClientFactorySolutionCommon.xml.
  8. Add the <Input Name=”SolutionPath” RecipeArgument=”SolutionDir” />  tag to each of these actions:
    • SaveRootNamespace
    • SaveShellProjectGuid
    • SaveCommonProjectGuid

    For example:
    <Action Name=SaveRootNamespaceType=Microsoft.Practices.SmartClientFactory.Actions.SetGlobalValueAction, Microsoft.Practices.SmartClientFactory.GuidancePackagePersistValue=trueValueName=RootNamespace>
    Input Name=SolutionPathRecipeArgument=SolutionDir/> <!–ADDED TAG TO ACTION–>
    Input Name=ValueRecipeArgument=RootNamespace/>

  9. Register the Guidance Package.

Steps to update the Source Control files

This steps are required if you have an existing solution that you want to use with the new Guidance Package:

  1. Open the solution file of the SCSF Solution for edit (i.e in notepad) and cut the Global Section(Extensibility Globals) section entirely. You will use the values from this section in the next step.
  2. Create an XML file in the same directory where your solution file is located named global.xml. Its content should be this:
    ShellProjectGuid>{YOUR SHELL PROJECT GUID}</ShellProjectGuid>
    CommonProjectGuid>{YOUR COMMON PROJECT GUIDE}</CommonProjectGuid>
    RootNamespace>{YOUR ROOT NAMESPACE}</RootNamespace>

    For example (using the values that you copied from the solution file):
  3. Check both files in.
  4. Open the solution in Visual Studio and check that the new Guidance Package is enabled.

In this way, the next time you open the solution in Visual Studio, the solution file should not be checked out.

I hope this helps you. Please, leave your comment if you have any doubt about the issue or the workaround.



Updating Prism-v2 Silverlight Applications to use dinamic module loading

The UX Patterns & Practices (Sustained Engineering) team has released a new article explaining the required steps to migrate the Composite WPF and Silverlight or Prism-v2 Reference Implementation: Stock Trader of the Prism-v2 Drop 10 to use dynamic module loading:

Basically, the explained steps in the article allow to define the modules of a Composite Silverlight Application (in this case, the Stock Trader RI) in an .xaml file, to avoid hardcoding the modules and the dependencies between them in the Bootstraper file. In this way, you will be able to get a similar behavior to the ProfileCatalog.xml file used in CAB (Composite Application Block – for classical desktop applications) where the modules are defined in a separated file.

Another advantage of using dynamic module is that you will have a xap file per module (for this reason, the article includes a section explaining how you can migrate a project from a Silverlight Application Library to Silverlight Application, because the modules are Silverlight Application Libraries and this kind of projects do not generate xap file, only the Silverlight Application Projects), in this way, if your application stops using a module, the module will not be downloaded saving bandwidth.

You should take into account that the article explains how you can migrate the Reference Implementation, but the steps can be executed to migrate other applications making little changes that you can distinguish easily.

Sharing experiences

  • The migration does not take a lot of time (2hs. approximately). Following the steps, this should take no more than 1hs. (Dependending on the amount of modules of your application).
  • We took into account the documentation included in the drop to perform the migration, specially we paid attention to the articles that explain what are the differents module loading alternatives:
    • Development ActivitiesHow to: Populate the Module Catalog from Code
    • Development ActivitiesHow to: Populate the Module Catalog from XAML
    • Development ActivitiesHow to: Populate the Module Catalog from a Configuration File or a Directory in WPF
  • Like I said before, with this module loading approach each module is packaged in a separated xap file. To avoid assemblies duplication in different modules, you should set in each module the Copy Local attribute of the references to false, if the Shell Project has a reference to that assembly too. You can find more information related about this in the article in the Prism-v2 documentation:
    • Development ActivitiesHow to: Prepare a Module for Remote Downloading (Specifically step 4)

I hope you can find useful the explication and the shared experiences in this post.


How-To: Perform Update Actions using an ObjectContainerDataSource with Entity Framework

The P&P Sustained Engineering team has published an article in the Known Issues / Fixes section of the WCSF Knowledge Base about how to perform updates objects from an ObjectContainterDataSource (OCDS) using Entity Framework (EF) correctly.

When using OCDS connected to an Entity Data Model (EDM), and try to accept the updates effectuated, no changes will be seen in the next postback. The cause of the problem is that the OCDS creates a new instance of the objects (entities) in each action performed and these are not binding correctly with the EF.

A possible workaround to solve this issue is modifying the Updated event raised by the OCDS to perform the following steps:

  • Retrieve the entity from the EDM again (to accomplish this we can use the Entity’s EntityKey property, that identifies the object and is like the primary key in the Relational Model).
  • Set the properties changed in the entity passed by the Updated event to the entity retrieved from the EDM.
  • Accept the change made in the model.

A code example of this can be found below:

public void OnOCDSUpdated(Model.Entity1 updatedEntity)
           Model.EDM ent = newModel.EDM();

           //retrieve the entity from the EDM (by primary key)
Model.Entity1 aux = ent.GetObjectByKey(updatedEntity.EntityKey) asModel.Entity1;

           if(aux != null)
               //overwrite the mapped values in the entity retrieved from the EDM
aux.Property1 = updatedEntity.Property1;
                aux.Property2 = updatedEntity.Property2;


The key of the solution is retrieving the object again from the EDM, this causes the EF’s properties in the retrieved object to be loaded correctly. Then, when we change the values in the properties of the object, so the EF knows about this. In this way, when we accept the changes done, the new values will be updated in the Database.

We also made a sample application to solve the problem. You can download it from here. Pay attention to the README.txt file and the prerequisites inside this, to run the solution without problems.

I hope you can find this useful and I would like to receive your suggestions and comments.



Add Read/Write runtime Settings to your Business Modules in Web Client Software Factory (WCSF)

Based on a question asked in the WCSF Forum, I start to search about how to add module specific settings. In this post, I will share with you a possible way to get this done.

A possible solution could be adding the settings in the web site’s root Web.Config. Although this works fine it is not the best approach, because we it couples the root Web.config and the modules. If we were to not load or eliminate the module, the settings will remain in the root Web.config anyways.

Basically, we will add settings in a new config file inside the business module and modify the existing Web.config to provide the name of the new config file. The new config file avoids our application to be restarted once the files are modified at runtime.

Then, we will create a global service in a new Foundational Module to access the settings and be able to save the changes made at runtime depending on the module being executed.

To accomplish this we must perform the following steps:

  1. Create a new Web Configuration File in the Business Module folder. In this file, we will define the module’s settings:
    <?xml version="1.0"?>
      <add key="Setting1" value ="1" />
      <add key="Setting2" value ="2" />

  2. Provide the specific name of the new config file in the configSource attribute of the appSettings section in the Web.Config inside the Business Module folder:
    <appSettings configSource="Settings.config"/>

  3. Create a new Foundational Module.
  4. Add a reference in the module to the System.Web assembly.
  5. Implement the global service that will provide us the module’s settings. Here is the code for the class:
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Web.Configuration;
    using Microsoft.Practices.CompositeWeb;
    using Microsoft.Practices.CompositeWeb.Interfaces;
    namespace WebClientApplication.ModuleSettings.Services
        public class ModuleSettingsService
            IVirtualPathUtilityService _virtualPath;
            IHttpContextLocatorService _context;
            Hashtable map;
            public ModuleSettingsService([ServiceDependency] IHttpContextLocatorService context,
                                         [ServiceDependency] IVirtualPathUtilityService virtualpath,
                                         [ServiceDependency] IModuleEnumerator moduleEnumerator)
                _virtualPath = virtualpath;
                _context = context;
                map = new Hashtable();
                foreach (IModuleInfo moduleInfo in moduleEnumerator.EnumerateModules())
                    if (moduleInfo.VirtualPath != string.Empty)
                        Configuration configuration = WebConfigurationManager.OpenWebConfiguration(moduleInfo.VirtualPath);
                        if (configuration != null)
                            map.Add(moduleInfo.VirtualPath, configuration);
            private string getCurrentVirtualPath()
                return _virtualPath.RemoveTrailingSlash(_virtualPath.GetDirectory(_context.GetCurrentContext().Request.AppRelativeCurrentExecutionFilePath));
            private Configuration getConfiguration()
                if (map.ContainsKey(this.getCurrentVirtualPath()))
                    return map[this.getCurrentVirtualPath()] as Configuration;
                    throw new Exception("There isn't configuration.");
            public KeyValueConfigurationCollection Settings
                get { return this.getConfiguration().AppSettings.Settings; }
            public void Save()
                map[this.getCurrentVirtualPath()] = WebConfigurationManager.OpenWebConfiguration(this.getCurrentVirtualPath());

    To understand how the service works, you should pay attention to the following class methods:

    • Constructor: Retrieves all the application’s modules and save their configuration in a map.
    • getCurrentVirtualPath Method: Identifies the virtual path based on the current context.
    • getConfiguration Method: Returns the correct configuration object based in the current virtual path.
  6. Set a dependency tag inside dependencies section of the Business Module Web.Config file to get the Foundational Module to be loaded before the Business Module is. <dependency module=ModuleSettings/>
  7. Inject the global service in your module. By doing this, you can get your settings values and save the changes at runtime. Here is an example:
    public DefaultViewPresenter([CreateNew] IModule1Controller controller,
                                [ServiceDependency] ModuleSettingsService settings)
         this._controller = controller;
         string a = settings.Settings["Setting1"].Value;
         string b = settings.Settings["Setting2"].Value;
         settings.Settings["Setting1"].Value = "new Value";

Another way to do that is using custom sections in the Web.Config. Read more about custom sections and how manipulate that in this msdn post.

I hope you can find this useful. Feel free to send your comments or suggestions.



Introduction to Applications supported by Composite UI Application Block (CAB)

When we are developing windows applications, one of the most important things is trying to eliminate the dependencies and relations between modules. If we achieve that, we will be able to develop and test the modules independently and more easily. Luckily the Composite UI Application Block (CAB) solves that for us.

The Composite UI Application Block (CAB) is useful for developing applications on scenarios with:

  • Complex user interface with different independent components.
  • Different windows applications that need to be integrated.

I will try to make you understand and know the principal components and parts in CAB. This post should be used a starting guide to understand and know this framework.

General Overview:

In applications that use the Composite UI Application Block (CAB) we can distinguish two kinds of projects:

  • Shell: This is a typical windows application, the objective is to manage the different application modules and show them to the user. This project has an xml file (ProfileCatalog.xml) that enumerates what modules are used and shown in the final application. Thus, we can eliminate the dependency in the code between the shell and the modules.
  • Modules: Modules are independent units, which contain a set of related functionalities, of a specific part of the application. We’ll see that with more detail below.

Introduction CAB 1


In this project, we’ll have a startup class that inherits from one of the different kinds of applications supported by Composite UI Application Block (CAB), which allows application initialization (In general, you are going to use the first two):

  • FormShellApplication: (Extends the WindowsFormsApplication) This is the most common, is a class that shows a Window Form at start up.
  • ApplicationContextApplication: (Extends the WindowsFormsApplication) In this, you don’t need to show a form at start-up process. You use that when you have a complex UI or your application is a plug-in for other systems.
  • WindowsFormsApplication: (Extends the CabShellApplication) This is a class that allows you to use shells based on Windows Forms and you can add more components to improve your application.
  • CabShellApplication: (Extends the CabApplication) Applications have to show a shell (which may or may not be a window) during start-up process.
  • CabApplication: It loads the minimal requirements to use the benefits of Composite UI Application Block.

The main form (In this example: FormShell) and the root WorkItem are set in the Shell application declaration:

public class Program : FormShellApplication<WorkItem, FormShell>

When the application starts, the FormShell form will be shown to the user. In the forms in general, you will be able to add, apart from the typical .NET’s Controls, Composite UI Application Block’s controls like:

  • Workspaces: With this we can show the different SmartParts of the WorkItems in different ways as the workspace you use:
    • WindowsWorkspace: The SmartParts will be shown in new windows.
    • MdiWorkspace: It is a CAB version of the MDI Forms.
    • TabWorkspace: It is a CAB version of the TabControl control.
    • DeckWorkspace: One of the most commons. When I give an SmartPart to how, this use all the assigned space to the Workspace.
    • ZoneWorkspace: You can define areas or zones (using panels) to show your SmartParts.
  • UIElements: These are UI elements to use from the different modules in a decoupled way. These might be ToolStrip, MenuStrip or StatusBars.



Like I said, we will develop the different parts of the final application in independents deployment units.

We will set an entry point to the module using a public class that inherits from Microsoft.Practices.CompositeUI.ModuleInit, and overriding the Load method we can decide what to do when the module is loaded.

public class ExampleModuleInit: Microsoft.Practices.CompositeUI.ModuleInit
     public override void Load()
           //Define what to do when the module is loaded here…

We will define different WorkItems to resolve a particular use case of our application. These kinds of classes have different objects containers for that, for example:

  • Items: Any kind of objects.
  • SmartParts: are User Controls with the [SmartPart] attribute that show visual elements.
  • Services: “a supporting class that provides functionality to other components in a loosely coupled” (Source: CAB documentation).
  • WorkItems: Child WorkItems.

Using those containers and ObjectBuilder’s features you can use dependency injection to improve your code and eliminate the dependencies between modules and blocks of code.

Introduction CAB 3

In the next post, I will try to give an introduction to Commands and Events (Event Broker): two important and useful CAB’s characteristics.

I hope you can use this and find it useful!



TDD with Examples: Chapter 4 and 5

English Version:

The Chapter 4 give an example of Degenerate Objects, this happens because you have a new Unit Test what change the requirements of your object. For solve this problem, you have to change the interface of the object to resolve the new requirement.

This chapter answer one of my Question about TDD, with this different strategies:

• Fake It—return a constant and gradually replace constants with variables until

you have the real code

• Obvious Implementation—type in the real implementation

I can’t imagine me programming using the methodology: try to get a green indicator using constant result and don’t think what is the better solution for the problem. Now, I know it’s not necessary to do that to be agree with TDD.

I’ll try to implement the theory of the author to solve different kinds of problems: If your problem is easy or you know how solve it, use the “Obvious Implementation”, when it’s more difficult, start using “Fake It”.

The Chapter 5 talks about the “side effects” in objects and the design pattern: value objects. If own objects don’t have “side effect” you don’t have to worry in this kinds of problems like aliasing. All operations with an object, return a new value objects. With this kind of objects , you can set their value only on the declaration.

A good practice is redefine the methods: “equals” and “hashcode” for produce if you have 2 objects with similar value, those have to return the same “hashcode” when you call the methods.

At the end of the chapter, The author explains what it’s the meaning of “triangulation”, for use that, you must have 2 examples to obtain the solution.

Spanish Version:

El capítulo 4 da un ejemplo de Objetos Deformados, esto sucede porque un nuevo test cambia los requerimientos de tu objeto. Para solucionar este problema, deberías cambiar la interfaz del objeto para resolver el nuevo requerimiento.

Este capítulo responde una de mis preguntas acerca de TDD, con las siguientes estrategias:

• Fake It—return a constant and gradually replace constants with variables until

you have the real code

• Obvious Implementation—type in the real implementation

No puedo imaginarme programando usando la metodología: intenta obtener un indicador verde usando resultados constantes y no pienses cual es la mejor solución para el problema. Ahora, sé que esto no es necesario de hacer para estar de acuerdo a TDD.

Voy a tratar de comenzar a implementar la teoría que presenta el autor para resolver los distintos tipos de problemas: Si tu problema es fácil o sabes cómo solucionarlo, usa la “Obvious Implementation”, cuando sea más difícil, empezá usando “Fake It”.

El capitulo 5 habla acerca del “side effects (Efecto de Lado)” en objetos y el patrón de diseño: Value Objects. Si nuestros objetos no tiene efecto de lado, no debemos preocuparnos en esta clase de problemas como “aliasing” (2 referencias a un mismo objeto). Todas las operación con un objeto, retorna un nuevo objeto. Con esta clase de objetos, puedes setear su valor solo en la declaración.

Una buena práctica es redefinir los métodos: “equals” y “hashcode” para producir que si tenés 2 objetos con el mismo valor, estos deben retornar el mismo hashcode cuando llames los métodos hashcode.

Al final del capítulo, el autor explica cual es el significado de “triangulación”, para usar esto, debes tener 2 ejemplos para poder obtener la solución.

First Habit: “Be Proactive” and TDD???

The author of “The seven Habits of Highly effective people” name the first habit: “Be Proactive”. The main of that is take the initiative to do or resolve things…

It’s the principal habit, and is a reference to improve the other six habits.

One of the most interesting think about this chapter, is the definition of your “circle of preoccupation” and your “circle of interest”. After that, You have to separate all your things in one of this 2 groups… The author recommends focus on the things are in your “circle of interest” because you can change this thinks directly. That’s produces you can focus only on the important things, like TDD… because that use the Unit Test to keep on your mind your main objective.

Do you agree with that? I’m waiting for yours comments.



My First Day

After my first day I’m very happy to meet a lot of interesant people to share knowledges and the workplace.

I readed about the organization and how to make the thinks. In the nexts days, I’m continuos reading the book: “Los 7 habitos de la gente altamente efectiva” to improve my personal skills and also I’ll try to learn the main of TDD (Test Driven Development).

Thanks to all people of SouthWorks for that oportunity.