0

我即将完成我的第一个 Windows 应用商店应用程序,过去两天我在使用 Windows 应用程序认证工具包进行应用程序测试期间遇到了问题。

测试在“崩溃和挂起”测试中失败,我收到以下消息:

Crashes and hangs
Error Found: The crashes and hangs test detected the following errors:
Application ....................0.0.12_x86__jarrs3vj594qe was detected by Windows Error Reporting and experienced a crash or hang.
Impact if not fixed: An app that stops responding or crashes can cause data loss and is a poor user experience.
How to fix: Investigate, debug the executable(s) in question to identify and fix the problem, then rebuild and re-test the app.

在调试模式下使用暂停和关闭进行一些测试后,我发现我的应用程序在以下情况下崩溃:运行 i 调试 => 暂停和关闭 => 再次在调试中运行。并且错误说 SuspensionManager 失败:weather.Common.SuspensionManager.RestoreAsync();

我认为这个问题与我的“扩展启动画面”有关,没有“扩展启动画面”我没有收到这个错误,并且应用程序通过了“崩溃和挂起”测试。这是 App.xaml.cs 和扩展启动画面的代码:

sealed partial class App : Application
{
    // Defining gloabal variables used across the App
    public string[] NavigateData { get; set; }
    public NavigationCacheMode NavigationCacheMode { get; set; }
    public parameterItem max1DayAgo = new parameterItem();
    public parameterItem min1DayAgo = new parameterItem();
    public parameterItem max1WeekAgo = new parameterItem();
    public parameterItem min1WeekAgo = new parameterItem();

    public parameterItem max1MonthAgo = new parameterItem();
    public parameterItem min1MonthAgo = new parameterItem();


public List<NameValueItem> tempTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> tempTrends30Days = new List<NameValueItem>();

    public List<NameValueItem> windSpeedTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> windSpeedTrends30Days = new List<NameValueItem>();


    public List<NameValueItem> windDirectionTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> windDirectionTrends30Days = new List<NameValueItem>();

    public List<NameValueItem> windChillTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> windChillTrends30Days = new List<NameValueItem>();

    public List<NameValueItem> humidityTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> humidityTrends30Days = new List<NameValueItem>();
    public string appBackgGround;

    public App()
    {
        this.InitializeComponent();
        this.Suspending += OnSuspending;       
    }


    protected async override void OnLaunched(LaunchActivatedEventArgs args)
    {

        //
        if (args.PreviousExecutionState == ApplicationExecutionState.Running)
        {
            Window.Current.Activate();
            return;
        }

        Frame rootFrame = Window.Current.Content as Frame;

        //Getting live tile data
        var uris = new List<Uri> 
                {
                    new Uri("..........WebService.asmx/GetFirstTile"),
                    new Uri("............./GetSecondTile"),
                    new Uri("................./GetStatisticTile"),
                    new Uri(".............../GetNewsTile1"),
                    new Uri("............../GetNewsTile2"),                
                };

        TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
        LiveTileUpdater.EnableNotificationQueue(true);  // Enable notifications
        LiveTileUpdater.Clear();  // Clear the current set of updates
        LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.HalfHour);

        //getting bacground image
        try
        {
            ServiceReference.WebServiceSoapClient webServiceObj = new ServiceReference.WebServiceSoapClient();
            appBackgGround = await webServiceObj.GetBackgroundImageAsync();// Get the name of the Background picture
        }
        catch
        {
         appBackgGround = "backgroundImageBlueSky.jpg";

        }



        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();
            weather.Common.SuspensionManager.RegisterFrame(rootFrame, "appFrame");

            // Her we set the application background Image for all pages  "backgroundImageBlueSky.jpg"
            rootFrame.Background = new ImageBrush
            {
                Stretch = Windows.UI.Xaml.Media.Stretch.UniformToFill,
                ImageSource = new BitmapImage { UriSource = new Uri("ms-appx:///Assets/" + appBackgGround) }

            };

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                    //TODO: Load state from previously suspended application
                    await weather.Common.SuspensionManager.RestoreAsync();

            }
            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (rootFrame.Content == null)
        {
           // Navigating to the extended splash screen
            if (!rootFrame.Navigate(typeof(ExtendedSplashScreen), rootFrame.GetNavigationState()))
            {
                throw new Exception("Failed to create initial page");
            }
        }
        // About page
        var _Helper = new Flyouts.SettingsHelper();

        _Helper.AddCommand<Flyouts.About>("About");
        Window.Current.Activate();
    }      
    private async void OnSuspending(object sender, SuspendingEventArgs e)
    {
        var deferral = e.SuspendingOperation.GetDeferral();
        //TODO: Save application state and stop any background activity
        await weather.Common.SuspensionManager.SaveAsync();
        deferral.Complete();
    }
}

扩展启动画面的代码:这里我做了一些 web 服务调用,以便为第一页加载数据。

public sealed partial class ExtendedSplashScreen : Page
    {


        public ExtendedSplashScreen()
        {
            this.InitializeComponent();
        }

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            /*
             * ........
             * ..........
             * ...........
             * ...........
             * ............
             * Here i do some webservice calls to get data for the first page(Mainpage
             * 
             */


            (App.Current as App).NavigateData = startupData;// save the data for the Mainpage to the Global variables

            this.Frame.SetNavigationState(e.Parameter as string);         
            this.Frame.Navigate(typeof(MainPage));// Finally navigate to the Mainpage
        }       
    }
}

有什么想法可以解决这个问题吗?

4

1 回答 1

0

您是否将您的 Visual Studio 2012 更新为更新 2?如果没有,请这样做并重试。无论如何,请确保启动时间不超过 5 秒,否则您将无法通过认证。

于 2013-04-20T18:44:57.620 回答