This is an odd one¡­

I have an CF Application (c#) that is deployed to several varieties of handheld devices. My application terminates when the user tries to enter data. The occurs only after the application comes out of hibernation, or power up. Sometimes, I get an error message asking if I want to send the report to Microsoft, other times, I get nothing at all ¨C the application just terminates without any warning.

Steps to recreate:

1) Launch Application
2) Go to a data collection window
3) Allow the device to power-down (hibernate)
4) Press the power button
5) Resume data entry.
6) Pow! Application crashes.

If you substitute step 4 and just press the power button, the same result can be accomplished.

Sometimes I get an error trap, other times, the application just terminates. The only device this occurs on is a Dell Axim x51V. I have been testing this on a Symbol 9090 and have not been able to reproduce the problem.

OS: Windows Mobile 5.0
CF: 2.0
VS: 2005
DB: SQLServerCE 3.0
Code: c#

Anyone encounter such a situation Additionally, is there a way to test the power-up/down in VS When I press the power button in debug mode, visual studio exits ¨C naturally because the device is no longer connected.

Re: .NET Compact Framework Application Crash on power resume

Ilya Tumanov

Do you have any components of your application (NETCF, SQL CE, etc.), native or managed, installed on to storage card If that¡¯s the case storage card driver might invalidate all handles to all files on a card upon sleep/wake cycle. OS (or NETCF for managed binaries) won¡¯t be able to swap out data because of that and your application (whatever it¡¯s managed or native) would terminate. Some devices come with better storage card drivers which would keep handles. In other case you cannot install anything on to storage card if termination is not acceptable (usually not a big deal on WM where OS can terminate application at any moment anyways). If your database is on such storage card you¡¯d need to handle error and reopen connection after wake/sleep cycle.

Re: .NET Compact Framework Application Crash on power resume


Yes, I have my SDF on an SD Card.

Is there a way to detect power-up/power-down

I am collecing a large amount of data and these Dell Axims do not have a large amount of ram.

Re: .NET Compact Framework Application Crash on power resume

Michael Koster

Yes there is:

Check the native APIs RequestPowerNotifications and StopPowerNotifications.

Do a search in the MSDN forums - there are various posts dealing with these APIs.

Here are some references: PostID=1322078&SiteID=1 pageindex=2&siteid=1&postid=8406

Hope this helps