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.