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

风格不统一 提交于 2020-01-01 03:10:11

问题


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:

  • Application crashes on exit when using Button2
  • Problem with CF 3.5 and Windows CE 6
  • Error on close

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.


回答1:


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()



回答2:


I've had this exact issue with the MC3190. The solution I found was to keep track of all forms that were opened in the application by adding each instance to a global List and upon application exit loop through the list and call a Form.Dispose on each item in the list. Has stressed me out for months.




回答3:


I encountered the same problem : Motorola MC3100, with wince6, only crashing at application exit when running standalone, and no crash when running with VS debugger attached. when crashed, the OS was HS and the only solution was to coldBoot the device.

And i manage to deal with it with the following solution.

My app was using Application.exit() in a modal sub form, and it seems it doesn't deal well with some unmanaged ressources used by font.

in my case the precise cause was to use new Font(...) in my main form. using it in modal subform didn't cause any issue.

Bringing back the application.exit() in the main form didn't work either, nor disposing explicitly font ressources (i made a lot of try oriented this way).

At the end the only solution i find that works was to quit the application by closing the mainform instead of using application.exit(), and it works well.




回答4:


Application.Exit() is not recommended way to close applications. Close all opened forms in order to close application.

http://blogs.msdn.com/b/tom_krueger/archive/2005/02/24/379678.aspx




回答5:


We experienced this issue with Motorola MC3190 devices running Windows CE 6.0 / .NET 3.5 CF. For months we were encountering an intermittent fatal error dialog upon closing our application. Every possible option was explored from ThreadAbort exceptions to making sure every single resource was properly disposed.

Normally, if a device doesn't have a particular font or is trying to access one that happens to be unrecognized, it will default to Arial. With the MC3190 however, if a font isn't recognized, the device will display a fatal error dialog and freeze after exiting an application. This results in the user having to warm boot (sometimes cold boot).

We came up with two solutions to this problem:

  1. Set the application-wide font to something that is supported (replace Tahoma with Arial)
  2. Reset any global Font objects either by instantiating with a supported font OR setting to null.



回答6:


You should make a Form and run your code in Application.Run() context. At the end of Run, many resources are disposed "by magic". Otherwise you must dispose every resources that need to be disposed.




回答7:


We encountered the same problem and solved with this line of code in the MainForm.Closed()

Process.GetCurrentProcess().Kill()



回答8:


I had the same problem on a Motorola 9190-G using the .NET Compact Framework 3.5. At times I would have to warm boot the device because it would freeze after closing my application.

I was able to workaround the issue by specifying the font of the form the ListView was contained in in the Constructor to be Arial, 10pt, Regular. I then programmatically set the font to my desired font. For example, myListView.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Bold);.

If I had the font set to any other font/font style/size combination, I would receive the "program encountered a serious problem and must shutdown" error message when closing the application on the mobile device.



来源:https://stackoverflow.com/questions/10709076/ce-6-0-net-cf-3-5-application-has-encountered-a-serious-error-mc3100

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!