Skip navigation


CAB Presenter Event Handlers Fire Multiple Times When Using SCSF
Fix: SCSF - Dispose Bug does not clean up instances

Purpose

This document explains how to fix the problem associated with the Guidance Packages not providing the correct code in the dispose method. 

Symptoms

The presenter will not be disposed when you disposed the view. For example, if you had an event handler in the presenter, it will fire as many times as the number of times you displayed the view.

Resolution

  • Open the file called View.Designer.cs.t4 located at “C:\Program Files\Microsoft SCSF\GuidancePkg\bin\Templates\Items\View”.
  • Change the dispose method to contain the following code: protected override void Dispose(bool disposing)  {   if (disposing)   {   if (_presenter != null && _presenter.WorkItem != null)   _presenter.WorkItem.Items.Remove(this);   if (_presenter != null)   _presenter.Dispose();if (components != null)   components.Dispose();   }base.Dispose(disposing);  }

This will cause the template to insert that code on NEW run Recipe code, but your existing code will need to be changed by hand.

Advertisement

2 Comments

  1. Thanks a lot for this code snippet. It solved a very frustrating problem.

  2. If you ever want to hear a reader’s feedback :) , I rate this post for 4/5. Detailed info, but I just have to go to that damn google to find the missed bits. Thank you, anyway!


Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.