Archive for July, 2008

Memory Leak Fix for DeckWorkspace in CAB Extensions for WPF

The P&P Sustained Engineering Team has found a fix for the DeckWorkspace memory leak issue of the Composite UI Application Block Extensions for WPF.

Content

Symptom

When you use a DeckWorkspace workspace to show a WPF View, the view will remain in memory even if you call its Dispose method from the presenter. This causes an increase in the memory usage.

Cause of issue

Summary: Some objects (like instances of LayoutEventArgs class) still reference to the View after it is disposed not allowing it to be swept from memory.

Full description: Using the ANTS profiler tool, we found out that there are some references to the WPF View that do not allow the View to be released from memory after it is shown in a DeckWorkspace workspace. The following figure shows the View2 still in memory even after it had been closed in our application. Should have been swept but the references shown in the bottom left do not allow that.

ANTS profiler

If you look at the Control class (DeckWorkspace inherits this class) using Reflector, you can see that there is a cachedLayoutEventArgs field that sometimes holds a reference to LayoutEventArgs, which ultimately holds a reference the view in this scenario. Once you call PerformLayout on the control, this reference gets released.

Fix

Summary: Call the PerformLayout method when a View is being closed in the DeckWorkspace, which releases all remaining references to the View.

Step by step: You will need to have installed the SCSF source code and perform the following steps to fix the issue:

  1. Open the CompositeUI-WPFExtensions.sln solution.
  2. Right-click in the DeckWorkspace.cs file located in the Workspaces folder on the CompositeUI.WPF project and then select View Code.
  3. Locate the Close method of the DeckWorkspace class and add the following bold line:
    public void Close(object smartPart)
    {
        composer.Close(smartPart);
    
        // Add this line.
        this.PerformLayout();
    }

  4. Locate the OnClose method of the DeckWorkspace class and add the following bold line:
    protected virtual void OnClose(Control smartPart)
    {
        this.Controls.Remove(smartPart);
    
        smartPart.Disposed -= ControlDisposed;
    
        ActivateTopmost();
    
        // Add this line
        this.PerformLayout();
    }

Download

Enjoy.

Technorati Tags: ,

New Recipe for the PageFlow Guidance Package Published!

Yesterday we added the “Enable Web Site or Web Application Project for Page Flow” recipe to the Page Flow Guidance Package.
To get this updated guidance package you must download the WCSFContrib source code and Register the Page Flow Guidance Package.

WCSF Contrib web site

Content

What does the recipe do?

This recipe adds configuration to the Web.config and the required assembly references to the Web Site/Web Application Project depending on the page flow implementation type that the user chooses (XML or Window Workflow Foundation provider).
The following files are the Web.config generated by the recipe:

The following references are added to the Web site/Web Application Project when the recipe is executed:

XML Window Workflow Foundation
  • WCSFContrib.PageFlow.dll
  • WCSFContrib.PageFlow.Xml.dll
  • WCSFContrib.PageFlow.Xml.Storage.EnterpriseLibrary.dll

 

  • WCSFContrib.PageFlow.dll
  • WCSFContrib.PageFlow.WorkflowFoundation.dll
  • WCSFContrib.PageFlow.Storage.EnterpriseLibrary.dll
  • System.Workflow.Runtime.dll
  • System.Workflow.ComponentModel.dll
  • System.Workflow.Activities.dll

How to use the recipe?

Once you have registered and enabled the Page Flow Development April 2008 guidance package in your solution, perform the following steps:

  • Right-click in a Web Site or a Web Application Project present in your solution.
  • Point to Page Flow and then click in Enable Web Site/WAP for Page Flow. The following wizard will appear:

Enable Web Site or Web Application Project for Page Flow

Figure 1 - Enable Web Site/WAP for Page Flow

  • Select the Page Flow implementation type that you want to use (XML or Window Workflow Foundation provider).
  • Choose the path where the Page Flow assemblies are. Depending on the Page Flow implementation type the assemblies required will change.
Note: The assemblies will be referenced from the specified location. Make sure that these are under source control.
  • Click in Finish.

Enjoy
Technorati Profile

SCSF - April 2008 with VS2008 + SP1 Known Issues

If you try to run SCSF - April 2008 in Visual Studio 20008 with Service Pack 1 Beta, you will face the following issues:

  • Running new SC-SF solutions will throw a ModuleLoadException exception when trying to load one of your modules.
  • The Add View (with Presenter) and Add WPF-View (with Presenter) recipes are not displayed in a new Visual Basic solution.

We’ve created an entry in the Known Issues / Fixes section of the SC-SF Knowledge Base where you can find the cause of these issues and the fixes we found. Any feedback is welcome.

Check the SCSF - April 2008 with VS2008 + SP1 Beta Known Issues article.

Enjoy!