CE 6.0 / .NET CF 3.5 Application has encountered a serious error (MC3100)

skeeve picture skeeve · May 22, 2012 · Viewed 7.9k times · Source

When exiting my .NET CF 3.5 application on the Motorola MC3100 (CE 6.0 version only) I get the error message "Application xxx has encountered a serious error and needs to shut down". I then need to warm boot the device for the application to work again.

This code works fine until the application is shutdown and it only fails if a font is set on a control in the application. Everything also works fine on .NET CF 2.0 and all of the other Motorola, Intermec, Psion, HHC devices I have tried with .NET CF 3.5.

Here is my current test code:

[MTAThread]
static void Main()
{
  Control oCtrl = new Control();
  oCtrl.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);

  // Setting the controls font to null works
  // oCtrl.Font = null;  Works

  // Setting the Control to null does not work, still get error
  // oCtrl = null;       Doesn't work

  // Setting a font, not on a control, also works fine.
  // System.Drawing.Font font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
}

I have seen a few links that seem related:

But so far the only recommendation I have found is to eliminate fonts in the application. In this case there is just too many places where fonts are set, including linked assemblies, that it would be impossible.

Has anyone else seen anything like this. It seems like something to do with the controls not properly disposing of the fonts on these versions.

Answer

user2755697 picture user2755697 · Sep 6, 2013

I faced exactly the same problem. Tried the following (none solved the issue):

  • Remove all the new Font() statements
  • Use Form.Close() instead of Application.Exit()
  • Move the whole application to .NET CF 3.5
  • Attempt to remove SQLite dependencies

The only solution that finally worked for our case, (however it is not a "pretty" solution), has been the following command in the MainForm.Closed()

Process.GetCurrentProcess().Kill()