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.
I faced exactly the same problem. Tried the following (none solved the issue):
new Font()
statementsForm.Close()
instead of Application.Exit()
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With