我正在开发Windows Phone 8应用程序。应用程序检测当前的地理坐标并尝试确定检测到的坐标的地址。 它可以在模拟器和我的设备(HTC 8X),家中(WLAN可用)以及外面的某个地方工作(即使移动设备上的“数据连接”(见下文)已关闭)。
我将应用程序部署到Microsoft Store并且Microsoft的认证过程返回了以下错误报告(我不允许上传报告的图像......):
Requirements
The app must handle exceptions raised by the any of the managed or native System
API and not close unexpectedly. During the certification process, the app is
monitored for unexpected closure. An app that closes unexpectedly fails
certification. The app must continue to run and remain responsive to user input
after the exception is handled.
Tip:
A Windows Phone 7 or 8 application may run flawlessly during development and testing,
but after submitting it for certification testing, the application may crash or
perform unexpectedly. Along these same lines, your application may not perform as
expected after publication.
This resource, http://support.microsoft.com/kb/2859130, explains the most common
reasons for this along with remedies.
Expected Result
1. Launch your app.
2. Navigate throughout the app, and then close the app.
3. Verify that unexpected behavior does not occur during the closing process.
4. Verify that the app remains responsive to user input and user interaction following
an app error.
Comments:
Result: Fail
When the device does not have an active data connection, the application terminates
unexpectedly in response to user input.
Steps to Reproduce:
1. Disable active data connections on the device.
2. Launch the application.
3. Enter valid details in 'SMS Contacts' and 'Settings' pages in Panoramic view.
4. Select 'red' button in 'Emergency Call' page in panoramic view.
5. Observe the application unexpectedly terminates.
我的问题: 我无法重现错误。
我的问题: 在“重现步骤”中,报告在“禁用设备上的有效数据连接”时的确切含义是什么?
这些是我手机上的当前设置:
在我的代码中,我插入了以下条件,但我不确定这是否真的可以解决问题:
if (!NetworkInterface.GetIsNetworkAvailable())
{
MessageBox.Show(AppResources.ErrMsg_NoDataConnection);
return;
}
有人有个好主意吗?
答案 0 :(得分:1)
在我看来,你应该启用Flightmode来禁用many things并调试扔你的应用程序 - 尝试每个按钮和选项。然后你应该看到你的应用程序崩溃的位置
为了确保您的应用程序可以处理所有情况,我会将那些有风险的代码(崩溃)放入try-catch块。然后根据抛出的异常,我会告诉用户。
当然你可以先检查网络并禁用一些选项,如果它不可用,这很好,但在这种情况下我也会检查带有Fligthmode的应用程序并将风险代码放入try-catch中 - 以防万一 - 它对你更好用户您的应用程序处理异常,而不是退出到开始。