2014-07-14 5 views
19

सिस्टम प्राप्त करना। ऑर्ग्यूमेंट अपवाद - घटना के लिए अपरिभाषित कीवर्ड मान 1 का उपयोग करें कार्य के लिए अपरिभाषित कीवर्ड मान 1 का उपयोग करें।ArgumentException - ईवेंट के लिए अपरिभाषित कीवर्ड मान 1 का उपयोग async

वहाँ कुछ गड़बड़ है जब दृश्य स्टूडियो 2013 अद्यतन 3.

मैं WP8.1 यूनिवर्सल और Silverlight क्षुधा के बाद मैं दृश्य स्टूडियो स्थापित उपयोग कर रहा हूँ के साथ एक यूनिवर्सल अनुप्रयोग में पहले इंतजार बयान चल रहा 2013 अद्यतन 3.

अपवाद एमुलेटर/डिवाइस मोड में होता है। मैंने बिना किसी संकल्प के इस मुद्दे पर शोध करने में कुछ दिन बिताए हैं।

मेरे पास विंडोज़ देव केंद्र मंच पर एक भाई लेख है लेकिन मैंने माइक्रोसॉफ्ट से कोई जवाब नहीं सुना है।

कोड सीधे आगे है। एक बार आंतरिक अपवाद फेंकने के बाद, प्रतीक्षा कभी वापस नहीं आती है।

क्या किसी और को 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; 
} 

पूर्ण अपवाद:

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: 

मैं एक नमूना परियोजना उपलब्ध है। एक शेल यूनिवर्सल ऐप बनाना और कुछ प्रतीक्षा कथन जोड़ना समस्या को फिर से शुरू करता है।

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

VS error

यहाँ 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(); 
    } 
+0

मैंने विंडोज फोन एसडीके, एमुलेटर और विजुअल स्टूडियो को हटा दिया है, और पुनः स्थापित किया है। सब कुछ स्थापित करने के बाद भी समस्या बनी रहती है !! कृपया –

+0

में मदद करें मुझे एक ही समस्या का सामना करना पड़ा - क्या आपने इसे काम किया? –

+1

एमएसडीएन फोरम में एक काम है: [माइक्रोसॉफ्ट इसे संबोधित करते समय हैक वर्कअराउंड] (http://social.msdn.microsoft।com/फ़ोरम/windowsapps/en-US/3e505e04-7f30-4313-aa47-275eaef333dd/systemargumentexception-use-of-undefined-keyword-value-1-for-event-functionscheduled-in-async? forum = wpdevelop) –

उत्तर

5

के लिए कॉल के साथ पूर्ण OnLaunched कोड अपवाद अनदेखा किया जा सकता है। बस खेल मारा। वैकल्पिक रूप से आप डीबग -> अपवाद मेनू में अपवादों पर ब्रेक को अक्षम कर सकते हैं।

enter image description here

+0

यह पहली जगह क्यों होता है? यह क्या संकेत करता है? –

+0

ढांचा आंतरिक रूप से अपवाद फेंकता है। जब तक यह उपयोगकर्ता कोड में नहीं आ जाता है, तब तक आपको चिंता नहीं होनी चाहिए कि यह क्यों हो रहा है। विजुअल स्टूडियो में डीबग विकल्प होना चाहिए जहां यह केवल उपयोगकर्ता कोड फेंक दिया अपवाद पर टूट जाता है। –

+8

यह स्वीकार्य नहीं है। जब भी वीएस को इस अपवाद को प्रदर्शित करने के लिए निष्पादन को रोकना पड़ता है तो यह एक परेशान समय बर्बाद करता है। फ्रेमवर्क में इतना फेंक मत बनो। –

0

मैं

using System.Runtime.InteropServices.WindowsRuntime; 

जोड़ने इस लाइन न निकालें द्वारा इस हल किया। स्वचालित "क्रमबद्ध करें और उपयोग हटाएं" (मेरे मामले में) इसे हटा देगा, जिससे यह गुप्त समस्या हो जाएगी। नहीं, मुझे नहीं पता क्यों। लेकिन मुझे पता है कि यह कारण है।

+0

मुझे यह कहां जोड़ना चाहिए? – seb

+0

आईआईआरसी, जहां आप कार्य का उपयोग कर रहे हैं, या केवल मुख्य में (जहां अपवाद बुलबुले के माध्यम से)। – Andy

+0

ऐसा कुछ नहीं लगता है। –

1

समस्या अभी भी मौजूद है, और अपवाद को अनदेखा किया जा सकता है क्योंकि अन्य उत्तरों ने कहा। लेकिन अगर एसिंक ऑपरेशन प्रयास/पकड़ से संलग्न है, तो अपवाद पकड़ा जाएगा और उसी प्रयास/पकड़ ब्रेस में अन्य ऑपरेशन निष्पादित नहीं किया जाएगा, यह समस्या है।

बस इसे एसिंक ऑपरेशन से पहले डालने से बेहतर होगा।

try 
{ 
    await Task.Delay(1); 
} 
catch 
{ 
    // do nothing 
} 

अपवाद अभी भी कार्य पर होता है। डेले (1), लेकिन उसके बाद यह एसिंक ऑपरेशन के बाद नहीं होगा।

संबंधित मुद्दे