ArgumentException - Use of undefined keyword value 1 for event TaskScheduled in async

c#, win-universal-app, windows-phone-8.1

Solution

The exception can be ignored. Just hit play. Alternatively you can disable break on exceptions in debug -> exceptions menu.

Problem

Getting System.ArgumentException - Use of undefined keyword value 1 for event TaskScheduled in async apis. There is something wrong when running the first await statement in an Universal app with Visual Studio 2013 Update 3. I am using WP8.1 Universal and silverlight apps after I installed Visual Studio 2013 Update 3. The exceptions happens in Emulator/Device modes. I have spent a couple of days researching this issue without any resolution. I have a sibling article at Windows Dev center forum but I have not heard any answers from Microsoft. The code is straight forward. Once the internal exception is thrown, the await never returns. Is anyone else having these issues with async ?? resolution ? ``` 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; } ``` Full exception: ``` 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: ``` I have a sample project available. Creating a shell Universal App and adding some await statement makes the problem reocur. ``` 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)); } ``` Here is the full OnLaunched code with calls to AsyncMethod ``` 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(); } ```

Original source

Related problems