Field Force Automation sample client crashes after reopening screen and keyboard

[CR #439409] The Field Force Automation sample client may crash if you open or close the onscreen keyboard in certain screens that have been opened, closed, and reopened.

This occurs because Microsoft .NET Compact Framework 2.0 does not properly remove the EnabledChanged event handler for InputPanel controls that are on screens that have been closed and removed from memory. Reinstantiation of a screen’s form class and opening the InputPanel on-screen keyboard can cause the EnabledChanged event to fire once for each time the screen has been previously instantiated since the client application was started.

Only one of the fired EnabledChanged events is for the current on-screen keyboard, while additional firings of the EnabledChanged events are for the InputPanel controls on the previously closed forms. For this reason, the InputPanel control is null for these additional firings of the EnabledChanged event. Any reference to the InputPanel control in the EnabledChanged event handler method results in a NullReferenceException, causing the application to crash.

Workaround: The Field Force Automation sample project released with Unwired Accelerator 8.0 already has the fix for this issue in the FormMain form class. For each of these forms, perform the steps listed below:

FormDailyPlanningEdit

FormJobs

FormDailyPlanning

FormMaterialOrderPartEdit

FormDailyReportEdit

FormMaterialOrders

FormDailyReportExpenseEdit

FormMaterialOrdersEdit

FormDailyReportHourEdit

FormPartSearch

FormDailyReports

FormRejectReason

FormJobDetails

FormSelectDateTime

FormJobReportActivityEdit

FormSettings

FormJobReportEdit

FormStatus

FormJobReportPartEdit

To fix the situation:

  1. Using Microsoft Visual Studio 2005, view the source code for a form class in the Field Force Automation sample project.

  2. Locate the Closing event handler method for the form.

  3. Locate the following two lines of code inside of the if(this._closeForm) code block:

    this.sip.Enabled = false;
    this.sip = null;
    

    Immediately before these two lines of code add:

    this.sip.EnabledChanged -= new
       System.EventHandler(this.sip_EnabledChanged);