ArgumentException - 对异步中的事件TaskScheduled使用未定义的关键字值1

Car*_*rez 19 c# windows-phone-8.1 win-universal-app

获取System.ArgumentException - 在异步apis中为事件TaskScheduled使用未定义的关键字值1.

使用Visual Studio 2013 Update 3在通用应用程序中运行第一个await语句时出错.

安装Visual Studio 2013 Update 3后,我正在使用WP8.1 Universal和silverlight应用程序.

例外情况发生在仿真器/设备模式中.我花了几天时间研究这个问题而没有任何解决方案.

我在Windows开发中心论坛上有一篇兄弟文章,但我没有听到微软的任何答案.

代码很简单.抛出内部异常后,await永远不会返回.

是否有其他人与async有这些问题?解析度 ?

public async Task<StorageFolder> FolderExists(StorageFolder parent, string folderName)
{
    StorageFolder result = null;
    try
    {
        // Exception happens here. The code never returns so the thread hangs
        result = await parent.GetFolderAsync(folderName);
    }
    catch (Exception ex)
    {
        if (FeishLogger.Logger.IsDebug)
            ex.LogException(() => string.Format("FolderExists File: {0}\\{1}", parent.Path, folderName));
    }

    return result;
}
Run Code Online (Sandbox Code Playgroud)

完全例外:

System.ArgumentException occurred
  _HResult=-2147024809
  _message=Use of undefined keyword value 1 for event TaskScheduled.
  HResult=-2147024809
  IsTransient=false
  Message=Use of undefined keyword value 1 for event TaskScheduled.
  Source=mscorlib
  StackTrace:
       at System.Diagnostics.Tracing.ManifestBuilder.GetKeywords(UInt64 keywords, String eventName)
  InnerException: 
Run Code Online (Sandbox Code Playgroud)

我有一个示例项目.创建一个shell Universal App并添加一些await语句会使问题重新出现.

private async Task AsyncMethod()
{
    Debug.WriteLine("({0:0000} - Sync Debug)", Environment.CurrentManagedThreadId);

    // Uncomment this line to make it work
    //await Task.Delay(1);

    // Fails only if the line above is commented
    await Task.Run(() => Debug.WriteLine("({0:0000} - Async Debug)", Environment.CurrentManagedThreadId));
}
Run Code Online (Sandbox Code Playgroud)

VS错误

以下是调用AsyncMethod的完整OnLaunched代码

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

            // TODO: change this value to a cache size that is appropriate for your application
            rootFrame.CacheSize = 1;

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

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

        if (rootFrame.Content == null)
        {
         #if WINDOWS_PHONE_APP
            // Removes the turnstile navigation for startup.
            if (rootFrame.ContentTransitions != null)
            {
                this.transitions = new TransitionCollection();
                foreach (var c in rootFrame.ContentTransitions)
                {
                    this.transitions.Add(c);
                }
            }

            rootFrame.ContentTransitions = null;
            rootFrame.Navigated += this.RootFrame_FirstNavigated;
         #endif

            await AsyncMethod();

            await AsyncMethods();
            await AsyncMethods();
            await AsyncMethods();


            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
            {
                throw new Exception("Failed to create initial page");
            }
        }

        // Ensure the current window is active
        Window.Current.Activate();
    }
Run Code Online (Sandbox Code Playgroud)

And*_*ehi 5

该例外可以忽略.只是打了一下.或者,您可以在debug - > exceptions菜单中禁用中断中断.

在此输入图像描述

  • 这是不可接受的.每次VS必须停止执行以显示此异常时,它会浪费一段烦人的时间.不要在框架中这么开心. (8认同)