Microsoft网站上的应用程序内购买教程的错误

时间:2012-12-20 03:21:56

标签: c# windows-8 microsoft-metro

我尝试为Metro应用实施应用内购买。我在这里按照教程。

C# code for in-app purchase

C#代码是

function AppInit()
{
    // some app initialization functions 

    // Get the license info
    // The next line is commented out for testing.
    // licenseInformation = CurrentApp.LicenseInformation;

    // The next line is commented out for production/release.       
    licenseInformation = CurrentAppSimulator.LicenseInformation;

    // other app initialization functions
}

但是,C#中没有function个关键字。这是错误的?如果是这样,假设正确的代码是什么?

1 个答案:

答案 0 :(得分:2)

该教程似乎错误地显示了代码的javascript版本。我在App类中有许可证初始化代码,在OnLaunched()函数中:

    protected override async void OnLaunched(LaunchActivatedEventArgs args)
    {
        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)
        {
#if DEBUG
            licenseInformation = CurrentAppSimulator.LicenseInformation;
#else
            licenseInformation = CurrentApp.LicenseInformation;
#endif

            // other init here...
        }
    }