Windows应用认证工具包:崩溃和挂起测试失败

时间:2013-04-19 12:22:43

标签: c# .net windows-8 microsoft-metro windows-store-apps

即将完成我的第一个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.

在调试模式下使用Suspension和Shutdown进行一些测试后,我发现我的应用程序在以下情况下崩溃:run i Debugging =>暂停和关机=>再次在Debugging中运行。并且错误说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();
    }
}

扩展的splash screeen的代码:这里我做了一些webservice调用,以便为第一页加载数据。

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
        }       
    }
}

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

1 个答案:

答案 0 :(得分:0)

您是否将visual studio 2012更新到更新2? 如果没有,请执行此操作并重试。 无论如何,请确保启动时间不超过5秒,否则您将无法通过认证。