Windows CE deletes .NET CF on reset

后端 未结 5 764
南笙
南笙 2020-12-25 09:05

I\'m writing a C# application for a proprietary Windows CE 4.2 device (for which I don\'t have the specs or pretty much any other information. I\'ve got access to the file s

相关标签:
5条回答
  • 2020-12-25 09:20

    I have brainstormed for hours and finally started writing a user guide for WinCE 7 based HW devices configuration and project building. Will be available shortly. Thanks SO for being a part of my research

    0 讨论(0)
  • 2020-12-25 09:21

    I know this is a very old question, but since I had the same issue as mentioned in the question I dit a lot of research to get it working. And I managed to do it without the use of a native bootstrap app.

    1) I used MSCEInf to extract the CF cab beforehand. I copied both the extracted data (which contains a \Windows folder) and the original cab on a SD card an inserted it into my device after if had fully booted up.

    2) Now, install the cab first, choose an empty folder (create one if nescessary) on that same SD card, or some other NAND storage.

    3) Copy the content of the \Windows folder you extracted from the CF cab earlier into the same folder where you installed the CF. If it prompts asking to overwrite any files, always choose "No".

    4) Make sure any apps that use/need the CF are located inside that same folder. You can place any subfolders, belonging to the app, intact there aswell.

    Anyway, that worked for me. The apps keep working, also after rebooting.

    Hope this helps!

    0 讨论(0)
  • 2020-12-25 09:22

    I think you need to run RegSave to save the registry settings after installing something. I had to do this in an older (pre .Net) version of Windows CE.

    0 讨论(0)
  • 2020-12-25 09:27

    There are a few Windows CE and CF behaviors that you're seeing here that's giving you this behavior. Unfortuantely there's no really good solution, but I can at least give you some guidance.

    1. Windows CE stores the current object store, including files in the filesystem not specifically on a persistent store in RAM. This includes any files and/or folders added to the \Windows folder (this is key in your case). When device power is lost - typically in a soft or hard reset, this data is lost.
    2. The CE registry can (and probably is on your device) be stored on a persistent store. This might be in the file system (as a hive) or in some non-visible location (there are two distinct ways an OEM can store it). This is not lost on reset. Only items saved and not flushed are lost.
    3. As an addendum to #2 - the registry changes are flushed when the RegFlushKey API is called. Installing a CAB automatically calls this (so installing the CF does). Some OEMs also choose to have it flush on a periodic timer.
    4. When the CF GACs an items not in the image, the file is moved to the \Windows folder. They are put back when the assembly is unloaded (I complained to the CF team about this years ago to no avail).

    What this means is that if you install the CF to a storage card and run your app this happens:

    1. CF files are copied to the persistent store during unpacking the CAB
    2. Installation reg keys are written
    3. Registry is flushed (saved)
    4. App runs
    5. CF files are moved (not copied) to \Windows, which is volatile.

    Now if you reset the device while the CF assemblies are loaded - poof! no more CF. Your app was on the storage card, but not in the GAC, so it survives but can no longer run.

    A hack solution: use a native app to "bootstrap" to launch your app. Have it check for the CF files in \Windows on run and if they aren't there install the CF CAB from a place in persistent storage (mark it as read-only so wceload won't delete it).

    The other option is to distribute the CF assemblies with your app and not GAC them.

    0 讨论(0)
  • 2020-12-25 09:34

    On my DataLogic Memor CE, I can now make a new .Net-installation survive a cold boot by manually saving the 'session' (whatever that means). It is located here:
    Start | Settings | Control Panel | Files Admin | Save session
    (The dialog remains open after pressing the 'Save session'-button, but you can just close that dialog.)

    This (obviously) still requires a manual action, so it's just another work-around.
    It's faster to apply for just a few devices (during development/try-out), but the extra installation-file or the hack-code by 'ctacke' are probably better for larger volumes.

    It also does imply there is a way to make a new .Net-installation persistent by software. So maybe someone might be triggered to figure out how to do that, and share it with the world?

    PS: I do not know how generic this manual saving is (if it applies to other devices or other brands or other CE-versions as well). Nor do I know if it is clean boot persistent.

    0 讨论(0)
提交回复
热议问题