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. 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
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:
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. Usually you don't access pointer directly in .NET, but those "Mem" classes may need some more investigation. 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.