UWP App认证Launchactivatedeventargs.Prelaunch

时间:2016-10-27 08:47:25

标签: windows-store-apps uwp app-certification-kit

我试图测试我的UWP应用程序,使用Microsoft App Certification Kit将其提交到商店。我唯一的问题是:

  

在应用程序的onleunched方法实现中,确保您处理launchchactivatedeventargs.prelaunch选项以预启动事件感知

我从未改变它,我使用Visual Studio中的原始项目

sealed partial class App : Application
{
    /// <summary>
    /// Initializes the singleton application object.  This is the first line of authored code
    /// executed, and as such is the logical equivalent of main() or WinMain().
    /// </summary>
    public App()
    {
        this.InitializeComponent();
        this.Suspending += OnSuspending;
    }

    /// <summary>
    /// Invoked when the application is launched normally by the end user.  Other entry points
    /// will be used such as when the application is launched to open a specific file.
    /// </summary>
    /// <param name="e">Details about the launch request and process.</param>
    protected override async void OnLaunched(LaunchActivatedEventArgs e) {
    #if DEBUG
        if (System.Diagnostics.Debugger.IsAttached) {
            this.DebugSettings.EnableFrameRateCounter = true;
        }
    #endif
        Frame rootFrame = Window.Current.Content as Frame;

        // 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();

            rootFrame.NavigationFailed += OnNavigationFailed;

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) {
                //TODO: Load state from previously suspended application
            }

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

        if (!e.PrelaunchActivated) {
            if (rootFrame.Content == null) {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(FormView), e.Arguments);
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }

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

    /// <summary>
    /// Invoked when Navigation to a certain page fails
    /// </summary>
    /// <param name="sender">The Frame which failed navigation</param>
    /// <param name="e">Details about the navigation failure</param>
    void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
    {
        throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
    }

    /// <summary>
    /// Invoked when application execution is being suspended.  Application state is saved
    /// without knowing whether the application will be terminated or resumed with the contents
    /// of memory still intact.
    /// </summary>
    /// <param name="sender">The source of the suspend request.</param>
    /// <param name="e">Details about the suspend request.</param>
    private void OnSuspending(object sender, SuspendingEventArgs e)
    {
        var deferral = e.SuspendingOperation.GetDeferral();
        //TODO: Save application state and stop any background activity
        deferral.Complete();
    }
}

我用Google搜索了一下,但每个人都在谈论UWP的Template10,例如来自此链接 App Certification fails because of PreLaunch Test

有什么建议吗?谢谢! Microsoft App Certification Kit Failed Result

2 个答案:

答案 0 :(得分:1)

是的,这是通过WACK的一种方式。有时包裹也可以通过商店认证,即使之前WACK失败了。

当您在Build部分的project属性下测试项目,然后检查“使用.NET工具链编译”时,表示您以“Release”模式运行项目。默认您的应用程序使用.NET Native工具链。由于包被编译为本机二进制文件,因此该包不需要包含.NET框架库。此外,该软件包依赖于最新安装的.NET Native运行时而不是CoreCLR软件包。设备上的.NET Native运行时将始终与您的应用程序包兼容。 通过“发布”配置进行本地本机编译,可以在与客户体验类似的环境中测试应用程序。 在您继续开发时,定期对此进行测试非常重要。

因为商店将测试您在.NET Native模式下提交的软件包,所以您将通过选中“使用.NET工具链编译”来传递认证。

此外,这里有关于.NET Native的an article,你可以参考它。

答案 1 :(得分:0)

我认为我找到了解决方案,但也许这只是一个幸运的巧合。

如果在 Build 部分的 Project Property 下,我选中了“使用.NET Native工具链编译”,现在结果为<强>传递

Visual Studio 2015 > Project Property

你认为这是正确的答案吗?