ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c# – 如何避免.NET CF 3.5和CE 6 R3中出现严重错误

2019-07-09 06:07:16  阅读:267  来源: 互联网

标签:c net compact-framework windows-ce


当我在带有附加调试器的设备上启动此示例程序时,会发生严重错误.

这是我们实际应用程序中发生的简化版本.

我发现的是:

>必须附加调试器
>内存必须以某种方式填充(我认为这将强制垃圾收集)
>垃圾(位图)对象必须存在.其他对象可能会导致相同的错误
>必须显示一个表单(如果使用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)

到目前为止我尝试过的事情:

>手动清理所有资源.我已经搜索了所有位图创建并处理或缓存它们.错误仍然存​​在,不仅是Bitmaps不好……

解决方法:

我有一个理论,那就是系统交换.如果调试器试图检索自己大小超过CE’s paging pool大小的变量的内容,我可以想象它会死锁.调试器停止系统读取数据,但系统无法提供内容,因为它无法交换数据.使用IOCTL_HAL_GET_POOL_PARAMETERS,您应该能够检测系统是否正在交换.

标签:c,net,compact-framework,windows-ce
来源: https://codeday.me/bug/20190709/1410011.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有