If you run an EXE that resides on an SD card, then while it is running, you turn off, wait a few seconds/minutes then turn back on, will the app continue to work correctly or will it crash because the PPC had to remount the card and reassign file handles
I developed an app, runs fine in main memory and runs fine on the SD card. However, when I power off, then on, the app will crash when it is on the SD card, but run fine it in main memory.
Any docs, PDFs, URLs that go into detail about this issue
Thanks,
Hilton

Power off/on with EXE on SD Card
Christoph Wienands
To test if it was related to the EXE or accessing the data files, I copied the EXE into its own temp directory on the card with no data files. The app is intelligent enough to handle missing data files. I ran the app, once it had initialized and got to the main screen I turned it off, waited a couple of minutes, turned it on. As I tried to display a dialog, I got:
ExceptionCode: 0xc0000005
ExceptionAddress: 0x01def4ac
Reading: 0x4bd61014
I tried the same test in main memory and the app does not crash.
Bottom line: 100% reproducable every time on a card with pwr off/on, 100% *not* reproducable in main memory with pwr off/on.
Summary of platforms:
X51, WM 5.0, CF 1.0 - crash
X51, WM 5.0, CF 2.0 - crash
X50v, WM 5.0, CF 1.0 - crash
Asus A636, WM 5.0, CF 1.0 - crash
X30, 2003 SE, no crash ever
Therefore, it seems that WM 5.0 is doing something that 2003 SE wasn't and it is causing the app to crash. If MS would like to track this down, let me know, I'll send you the EXE.
FYI: I'm not doing any unsafe stuff, it's all standard C# code/objects.
Thanks,
Hilton
David_Reynolds
I’ve tried your scenarios with my small 2 assembly test application, works just fine from CF card, does not matter if it’s removed or device goes through sleep/wake cycle. Application continues to run properly, no issues.
My take to it is: if it’s indeed “assembly paging” issue, it should’ve crashed and since it did not it probably related to something your application is doing what mine does not (e.g. no P/Invoke).
Of course, it might have something to do with, say, application size, but for NETCF V2 SP1 we’ve done quite a few tests with all BCLs (~5MB) located on a storage card which was removed in mid-flight as well as device been cycled through sleep/wake and we saw no issues.
Here’s my suggestion: try to create a repro application by eliminating stuff from your whole code (starting with P/Invokes). In the process you might find the cause for the AV or I will get a bare bone code to look at if that’s indeed NETCF issue. We also can’t rule out hardware issues here, I do have access to x51v if needed.
Thanks.
Jinlin Chen
I'm running an Dell Axim X51, WM 5.0, SD Card, no special drives installed. The app seems to crash randomly but always pretty soon after a pwr off/on (app never crashes when in main memory and/or with no pwr off/on). The app does access files, but my main concern is: The app itself will be paged in over time, compiled etc, so there's nothing I can do to stop the app crashing - right Then the larger picture: So no EXEs can run reliably on a card. Maybe it is just me but this seems to be a HUGE problem with the PPC design.
So, the obvious solution is to put the EXE in main memory and the databases on the card. Then on power on, we need to re-initialize the file reading, streams etc. To complicate things, the code might have been stopped while reading from and/or writing to the SD card, so exceptions will get thrown all over the place. Again, the enormity of this problem leaves me speechless; maybe it's just me, but wow.
How about CF 2.0 SP2 copies EXE to main memory before running it
Hilton
Sabrecat
HelpMePl0x
That is a simple AV which you can get for any number of reasons including bug in NETCF code or bug in your code. With managed code that most commonly due to managed memory been passed to native code been collected or moved or improperly allocated (e.g. on a stack) native memory been passed to managed code while using P/Invoke.
I would suggest another simple test: remove storage card while application is running and see if it would AV in that case. Obviously card access won't be possible with card out, but GC which moves/collects memory won't be triggered.
And, sure, you can mail me your code and exe (just exe won't do), I would be happy to give it a try. Please remove "online" from my e-mail address before mailing anything. If you have any VB files, please rename them to .vb.txt. Thanks.
sandeepam
I think the small test application won't page because it is small. I created a test case that simply does:
Form form00001 = new Form00001(); form00001.Show(); form00001.Dispose();
:
Form form00099 = new Form00099(); form00099.Show(); form00099.Dispose();
i.e. 100 separate Form classes. Runs in main memory fine, runs fine on card, crashes when I remove card. I will email the EXE to you. If you want the source let me know. It is all pure C#, no other code that what VS 2003 generated to create the blank app (New, Project) and the lines you see above.
Thanks,
Hilton
Divermarv
I'd like more on this one. I've had a few customers that have had the same experience - running an app from mountable storage fails after a sleep wake. The failure was not immediate - it usually required a few actions, but it was always predictable and reproducable. I saw it on more than one manufacturers device, and copying the app to RAM before running always eliminated the error.
I'd always assumed it was a paging problem, becasue it made sense based on the behavior - just like having an open database on mountable storage fails after a sleep wake.
What else could be causing this
Fluxtah
I suspect you are correct and that is memory mapped file paging done by the OS. It looks like NETCF maps managed assemblies this way so they won't eat up virtual memory of the process. If assembly is strong named, it is likely to be fully loaded into memory as validation process accesses entire assembly. Normal assembly would be accessed as needed by JIT. If storage card is gone/inaccessible, OS can't access the file and what happens after that is a bit of a mystery to me. I would expect “Insert storage card with 'whatever.file'” message from the OS similar to “Insert disk with COMMAND.COM into drive A:” from DOS 20 years ago. Whatever it is, NETCF should not AV, MissingMethodException or TypeLoadException wouldb be more reasonable. I will look into it and keep you posted.
Colin Bowern
Apps are not paged and NETCF loads modules into memory as whole keeping them in memory at all times. NETCF can pitch JITed code, but not managed assembly. What is the error you see
szolDat
With the app in its own directory (i.e. no data files), I ran it, after it had got to the main screen, I removed the SD card and then pretty much anything I did caused it to crash - even just tapping on the main menu - pretty much anything.
So, my conclusion, is that WM 5.0 is paging in the app which is why the pwr off/on problem occurs. You agree
FYI: I tried the exact same test with the X30 running 2003 SE and this time I saw the crash (first time on 2003SE).
Thanks,
Hilton