简体   繁体   English

使用 Compact Framework 3.5 的 wince 应用程序中的资源损坏

[英]corrupted resources in wince application using Compact Framework 3.5

I'm maintaining a windows ce form application developed on compact framework 3.5 The problem that i'm struggling with is that the application running on a windows ce 6.0 device after a few days of working crashes.我正在维护在紧凑框架 3.5 上开发的 windows ce 表单应用程序我正在努力解决的问题是,在经过几天的工作崩溃后,该应用程序在 windows ce 6.0 设备上运行。 It presents an exception:它提出了一个例外:

SerializationException 255 at Systems.Resources.ResourceReader.ParseMessageEnd() at
System.Resources.ResourceReader.LoadBitmap(Int 32 typeIndex) etc

I've used then.Net Reflector to analyse the exe file that runs on the device and I found out that some resources are corrupted and they have a value: Invalid resource TypeCode '-1' and the type is System.BadImageFormatException, mscorlib, Veersion=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 whilst the non corrupted resources have Version=2.0.0.0我使用 then.Net Reflector 来分析设备上运行的 exe 文件,我发现一些资源已损坏并且它们有一个值: Invalid resource TypeCode '-1' and the type is System.BadImageFormatException, mscorlib, Veersion=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 whilst the non corrupted resources have Version=2.0.0.0

It's really strange how the files get corrupted and the version changes.文件如何损坏以及版本如何更改真的很奇怪。 I also found in the code a 200ms timer that runs forever and in that timer there was also this code which caused a lagging in the ui:我还在代码中发现了一个永远运行的 200 毫秒计时器,并且在该计时器中还有这段代码导致了 ui 滞后:

if (Global.ParSotteraneiQuadro.typepompa == ClParSottQuadro.EnTipoPompa.PNEUM)
        {
            ImagesMOTORE[0] = Resources.pump_OFF;
            ImagesMOTORE[1] = Resources.pump_OFF;
            ImagesMOTORE[2] = Resources.pump_ON;
            ImagesMOTORE[3] = Resources.pump_ON;

            btPompa.ImageBack = Resources.pump_OFF;
            btPompa.ImageFore = Resources.pump_ON;

            MemImageMOTORE = new ClassMemImage(ImagesMOTORE);

            ImagesTempWait[0] = Resources.anim12_230;
            ImagesTempWait[1] = Resources.anim22_230;
            ImagesTempWait[2] = Resources.anim32_230;
            ImagesTempWait[3] = Resources.anim42_230;
            ImagesTempWait[4] = Resources.sfondo_arancio; // arancione vuoto
            ImagesTempWait[5] = Resources.sfondo_red; // rosso vuoto
            ImagesTempWait[6] = Resources.warning_230;
            ImagesTempWait[7] = Resources.ok_230;
            ImagesTempWait[8] = Resources.eco_top;
            ImagesTempWait[9] = Resources.abil_pompa_pump;
            ImagesTempWait[10] = Resources.abil_24VOLT_sfumato;
            ImagesTempWait[11] = Resources.ok_230_giallo;

            MemImageWaitTemp = new ClassMemImage(ImagesTempWait);
        }
        else
        {
            ImagesMOTORE[0] = Resources.motor_OFF;
            ImagesMOTORE[1] = Resources.motor_OFF;
            ImagesMOTORE[2] = Resources.motor_ON;
            ImagesMOTORE[3] = Resources.motor_ON;

            btPompa.ImageBack = Resources.motor_OFF;
            btPompa.ImageFore = Resources.motor_ON;

            MemImageMOTORE = new ClassMemImage(ImagesMOTORE);

            ImagesTempWait[0] = Resources.anim12_230;
            ImagesTempWait[1] = Resources.anim22_230;
            ImagesTempWait[2] = Resources.anim32_230;
            ImagesTempWait[3] = Resources.anim42_230;
            ImagesTempWait[4] = Resources.sfondo_arancio; // arancione vuoto
            ImagesTempWait[5] = Resources.sfondo_red; // rosso vuoto
            ImagesTempWait[6] = Resources.warning_230;
            ImagesTempWait[7] = Resources.ok_230;
            ImagesTempWait[8] = Resources.eco_top;
            ImagesTempWait[9] = Resources.abil_pompa;
            ImagesTempWait[10] = Resources.abil_24VOLT_sfumato;
            ImagesTempWait[11] = Resources.ok_230_giallo;

            MemImageWaitTemp = new ClassMemImage(ImagesTempWait);
        }

Has someone faced something like this?有人遇到过这样的事情吗? Thank you for your help谢谢您的帮助

IIRC resources are loaded in writable memory, this means that application may overwrite that data if the pointers are used in the wrong way. IIRC 资源以可写的 memory 加载,这意味着如果以错误的方式使用指针,应用程序可能会覆盖该数据。 Usually you don't access pointer directly in .NET, but those "Mem" classes may need some more investigation.通常您不会直接在 .NET 中访问指针,但那些“Mem”类可能需要更多调查。 And just a small not on performances, maybe all the assignments and allocations should be done only if Global.ParSotteraneiQuadro.typepompa has changed since the last check.并且只是一个很小的性能,也许只有当 Global.ParSotteraneiQuadro.typepompa 自上次检查以来发生了变化时,才应该完成所有的分配和分配。

To autorun from external storage on insert:要在插入时从外部存储自动运行:

"Auto-Run Applications on Compact Flash Cards Starting with Windows CE 3.0 it is possible to have an application run from a Compact Flash memory card when it is inserted into a device. This allows an application to auto-install from a Compact Flash card. To set an application to be auto-run, you must place the application in aspecific folder for the CPU targeted by your application. The folder name isbased on the CPU number returned in the dwProcessorType member of theSYSTEM_INFO structure returned from calling GetSystemInfo. Table 3.7 shows the possible values and their associated constants. Constant Value PROCESSOR_MIPS_R4000 4000 PROCESSOR_HITACHI_SH3 10003 PROCESSOR_HITACHI_SH3E 10004 PROCESSOR_HITACHI_SH4 10005 PROCESSOR_MOTOROLA_821 821 PROCESSOR_SHx_SH3 103 PROCESSOR_SHx_SH4 104 PROCESSOR_STRONGARM 2577 PROCESSOR_ARM720 1824 PROCESSOR_ARM8 "Auto-Run Applications on Compact Flash Cards Starting with Windows CE 3.0 it is possible to have an application run from a Compact Flash memory card when it is inserted into a device. This allows an application to auto-install from a Compact Flash card.要将应用程序设置为自动运行,您必须将应用程序放置在应用程序所针对的 CPU 的特定文件夹中。文件夹名称基于调用 GetSystemInfo 返回的 SYSTEM_INFO 结构的 dwProcessorType 成员中返回的 CPU 编号。如表 3.7 所示the possible values and their associated constants. Constant Value PROCESSOR_MIPS_R4000 4000 PROCESSOR_HITACHI_SH3 10003 PROCESSOR_HITACHI_SH3E 10004 PROCESSOR_HITACHI_SH4 10005 PROCESSOR_MOTOROLA_821 821 PROCESSOR_SHx_SH3 103 PROCESSOR_SHx_SH4 104 PROCESSOR_STRONGARM 2577 PROCESSOR_ARM720 1824 PROCESSOR_ARM8 20 2080 PROCESSOR_ARM920 2336 PROCESSOR_ARM_7TDMI 70001 Table 3.7. 20 2080 PROCESSOR_ARM920 2336 PROCESSOR_ARM_7TDMI 70001 表 3.7。 Processor values and associated constants Thus, if you want your application to auto-run and the application is compiled for MIPS, you should rename your application to autorun.exe and place it in a folder called \4000, for example, \4000\autorun.exe.处理器值和相关常量 因此,如果您希望您的应用程序自动运行并且该应用程序针对 MIPS 进行编译,您应该将您的应用程序重命名为 autorun.exe 并将其放在名为 \4000 的文件夹中,例如 \4000\autorun 。可执行程序。 If your application is compiled for CEF (Common Executable Format), you should place the autorun.exe file in a folder called \0, for example, \0\autorun.exe.如果您的应用程序是针对 CEF(通用可执行格式)编译的,您应该将 autorun.exe 文件放在名为 \0 的文件夹中,例如 \0\autorun.exe。 The application autorun.exe is passed the command line parameter "install" when a Compact Flash card is inserted, and with the command line parameter "uninstall" when the card is removed.应用程序 autorun.exe 在插入 Compact Flash 卡时传递命令行参数“install”,在移除卡时传递命令行参数“uninstall”。 This allows your autorun.exe application to uninstall itself when the card is removed.这允许您的 autorun.exe 应用程序在卡被移除时自行卸载。 ..." [From book: Windows CE 3.0 Application Programming] ...” [来自书籍:Windows CE 3.0 应用程序编程]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM