当我在带有附加调试器的设备上启动此示例程序时,会发生严重错误.
这是我们实际应用程序中发生的简化版本.
我发现的是:
>必须附加调试器
>内存必须以某种方式填充(我认为这将强制垃圾收集)
>垃圾(位图)对象必须存在.其他对象可能会导致相同的错误
>必须显示一个表单(如果使用Application.Run()或ShowDialog则没有区别)
然后,当表单可见并且GC收集位图时,会发生严重错误.
我正在使用.NET Compact Framework 3.5运行WindowsCE 6 R3.
static class Program { static void Main() { // Fill up memory - Depends on device var memory = new int[100000 * 150]; // Settings the priority higher will raise the error earlier. // With Priority set to normal the EXE won't get freed correct. // Without this line i have to reboot the CE after every test run... Thread.CurrentThread.Priority = ThreadPriority.Highest; // 80 is just random choosen. The error occurs also with 30 Bitmaps... for (int o = 1; o < 80; o++) { // Create a Bitmap and don't free it manually. The // The garbage collector will take care of it :) var bitmap = new Bitmap(100,100); // When i dispose the Bitmap,everything works fine... //bitmap.dispose(); } // Force a GC run System.Diagnostics.Debug.WriteLine(GC.GetTotalMemory(true)); // Then error occurs when the form is shown. System.Windows.Forms.Application.Run(new System.Windows.Forms.Form()); } }
我已经找到了类似的问题,但没有回答……
> How to debug a fatal error that happens after calling Application.Exit() in .NET CF 3.5 WinForms application for Windows CE 6?
> CE 6.0 / .NET CF 3.5 Application has encountered a serious error (MC3100)
到目前为止我尝试过的事情: