Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a number of reasons that this can happen. It's hard to pinpoint precisely what's going on without some debug output, but here is a brief run down of the likely culprits:</p> <h3>Most Likely...</h3> <p>The most likely thing that's causing your app to crash in non-debug mode is poor start up time. I suspect you may be encountering what <a href="https://stackoverflow.com/questions/4594891/wp7-application-working-only-on-emulator-and-on-device-when-debugging">this S.O. question</a> is all about. When the debugger is attached, the runtime bypasses the operating system's function of killing any app that takes longer than 10 seconds to load. This is an easy thing to test for, simply remove all the code that's being executed when the app starts up (I'm assuming you're hooking into GPS stuff at that moment, just comment that stuff out).</p> <h3>But Additionally...</h3> <p>While the above might solve your problem, you have to be wary of a few other issues you may also encounter:</p> <p>When you access the GPS / Accelerometer / Compass you <em>must</em> check first to see if those sensors are actually accessible and provided by the phone. Not all windows phones are required to provide the compass. Take a look at the <a href="http://msdn.microsoft.com/en-us/library/ff637514(v=vs.92).aspx" rel="nofollow noreferrer">Hardware Specifications for Windows Phone</a>. If you are trying to access the compass, and your device does not support the compass, then that could be your problem right there. More details on this <a href="http://msdn.microsoft.com/en-us/library/hh202974(v=vs.92).aspx" rel="nofollow noreferrer">here</a>. The following code is an example of how you might check for the presence of the Compass on the device (note that the IsSupported will return true even if your device has the compass off).</p> <pre class="lang-cs prettyprint-override"><code>using Microsoft.Device.Sensors; public partial class MainPage : PhoneApplicationPage { Compass compass; public MainPage() { if (Compass.IsSupported) { // awesome. you have a compass } else { // uh oh… you have a crappy phone, no compass for you :( } } } </code></pre> <h3>Have You Tried Turning It On And Off Again?</h3> <p>One of the other things you have to consider is that the device you are using has the GPS turned off (greater developers than you I am certain have made more foolish mistakes). If your GPS is turned off, or disabled, or the user (you, there, holding the device) <em>has not authorized the app to use GPS data</em>. See <a href="http://create.msdn.com/en-US/education/quickstarts/Developing_with_the_Windows_Phone_GPS_(Location_Services)" rel="nofollow noreferrer">this article</a> for dealing with the location considerations alone (a must-read if you're developing GPS enabled WP7 apps anyways).</p> <h3>Declare Your Intentions Sir</h3> <p>Lastly, there can be issues if you don't declare the things you're accessing from the device in the <a href="http://msdn.microsoft.com/en-us/library/ff769509(v=vs.92).aspx" rel="nofollow noreferrer">application manifest file</a>. Basically, if you don't declare those as items your app uses, you can run into problems. The reason you need to declare what you're app uses is so that Microsoft can appropriately filter/warn/inform users who are downloading your app from the marketplace of the information your app requires to operate.</p> <h3>Battery Saver Mode</h3> <p>When a Windows Phone is in <a href="http://www.microsoft.com/windowsphone/en-us/howto/wp7/basics/battery-making-it-last.aspx" rel="nofollow noreferrer">battery saver mode</a> some of the sensors will be turned off to save battery life (things like... GPS, Compass, and Accelerometer). This could easily happen if your device isn't actually charging when it's plugged into your dev machine.</p> <h3>In Summary:</h3> <ul> <li>Check to see if your app is taking longer than 10 seconds to load</li> <li>Make sure the device actually supports the sensors you are trying to access</li> <li>Make sure that the data returned by the sensors is not causing your code to crash (for instance GPS may be on, but give a lat/long that is, according to your code errant, causing it to crash).</li> <li>Make sure you declare usages in the application manifest file</li> <li>Make sure your sensors are ON and you're not in battery saver mode</li> </ul> <p>Hopefully one or all of the above helps you diagnose your problem. Lemme know if you find out that it's something else, would be curious to know what else could be causing this problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload