2016-04-23 123 views
5

我的UWP應用程序在發佈模式下崩潰,並且在調試模式下正常工作,但我無法指出問題是什麼,但我知道它與從System.Threading.Timer和MVVMLight引發事件的組合。UWP Windows 10應用程序在發佈模式下崩潰,但在調試模式下正常工作

我創建了一個新的虛擬應用程序並使用相同的代碼(ZXing.net.mobile,我使用了2個便攜式庫,並使用了我自己的用戶控件,這是他們的簡化版本 - 我使用事件代替<Action> )。這工作正常,我目前正試圖把更多的步驟,即包括mvvmlight和導航,但到目前爲止,我不能在這個虛擬應用程序重現問題。

我得到的錯誤是:

Unhandled exception at 0x58C1AF0B (mrt100_app.dll) in Company.MyApp.App.exe: 
0xC0000602: A fail fast exception occurred. Exception handlers will not be 
invoked and the process will be terminated immediately. 

其次:

Unhandled exception at 0x0107D201 (SharedLibrary.dll) in 
Company.MyApp.App.exe: 0x00001007. 

當尋找在線程窗口,工作線程中的一個具有以下信息,如果這是幫助。

Not Flagged > 4012 0 Worker Thread <No Name> 
    System.Private.Interop.dll!System.Runtime.InteropServices. 
    ExceptionHelpers.ReportUnhandledError Normal 
    [External Code] 
    System.Private.Interop.dll!System.Runtime.InteropServices.ExceptionHelpers. 
    ReportUnhandledError(System.Exception e) Line 885 
    System.Private.Interop.dll!Internal.Interop.InteropCallbacks.ReportUnhandledError 
    (System.Exception ex) Line 17 
    System.Private.WinRTInterop.CoreLib.dll!Internal.WinRT.Interop.WinRTCallbacks. 
    ReportUnhandledError(System.Exception ex) Line 274 
    System.Private.CoreLib.dll!System.RuntimeExceptionHelpers.ReportUnhandledException 
    (System.Exception exception) Line 152 
    System.Private.Threading.dll!System.Threading.Tasks.AwaitTaskContinuation. 
    ThrowAsyncIfNecessary(System.Exception exc) Line 784  
    System.Private.Threading.dll!System.Threading.WinRTSynchronizationContext.Invoker. 
    InvokeCore() Line 182 
    System.Private.Threading.dll!System.Threading.WinRTSynchronizationContext.Invoker. 
    Invoke(object thisObj) Line 162  
    System.Private.CoreLib.dll!System.Action<System.__Canon>. 
    InvokeOpenStaticThunk(System.__Canon obj) 
    System.Private.WinRTInterop.CoreLib.dll!Internal.WinRT.Interop.WinRTCallbacks.PostToCoreDispatcher.AnonymousMethod__0() Line 266  
    MyCompany.MyApp.App.exe 
    MyCompany.MyApp.App.ViewModels.ValidateHandler.Invoke(string pin) 
    MyCompany.MyApp.App.McgInterop.dll!McgInterop.ReverseComSharedStubs 
    .Proc_(object __this, System.IntPtr __methodPtr) Line 6163 
    MyCompany.MyApp.App.McgInterop.dll!Windows.UI.Core.DispatchedHandler__Impl.Vtbl.Invoke__STUB(System.IntPtr pComThis) Line 45147  
    [External Code] 

在我的QR碼用戶控件,它使用System.Threading.Timer和它提出了當QR碼被發現的事件:

timerPreview = new Timer(async (state) => 
{ 
    .... 
    // Check if a result was found 
    if (result != null && !string.IsNullOrEmpty(result.Text)) 
    { 
    Debug.WriteLine("Barcode Found: " + result.Text); 
    if (!this.ContinuousScanning) 
    { 
     delay = Timeout.Infinite; 
     await StopScanningAsync(); 
    } 
    else 
    { 
     delay = this.ScanningOptions.DelayBetweenContinuousScans; 
    } 
    OnBarcodeFound(result.Text); 
    } 

    timerPreview.Change(delay, Timeout.Infinite); 

}, null, 
    this.ScanningOptions.InitialDelayBeforeAnalyzingFrames, 
    Timeout.Infinite); 

在頁面承載QR碼用戶控件,我「已經得到了下面的代碼:

private async void ScannerControl_BarcodeFound(string barcodeValue) 
{ 
    var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; 

    await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,() => { 
     Debug.WriteLine(barcodeValue); 
     GetViewModel.BarcodeFound(barcodeValue); 
    }); 
} 

正如你所看到的,我的QR碼值傳遞給我的視圖模型,並從那裏,我發了消息,然後重新定向到另一個頁面:

public void BarcodeFound(string barcodeData) 
{ 
    Messenger.Default.Send<string>(barcodeData, MessengerTokens.QrCodeFound); 
    this.NavigationFacade.NavigateToMyOtherPage(); 
} 

我可以繼續前進並提供額外的代碼,但是當我添加額外的斷點時,我可以看到代碼並傳遞正確的值並轉到正確的位置,但最終引發此錯誤。如果我添加額外的錯誤處理程序或調度程序代碼,它最終會按預期工作並進入下一頁,但是當我點擊CommandBar中的按鈕時,它需要一段時間,最終會拋出相同的錯誤,因此通過添加這些附加代碼中的一小部分,我覺得我只是將問題推到了最後。

任何人都有如何解決這個問題的任何建議。我希望我可以分享完整的應用程序,但肯定不能。所以我知道這將很難提供解決方案,但如果有人有建議,我會很感激他們。

正如我所說的,我認爲這個問題是由線程和mvvmlight的結合導致的,但它讓我堅信我的測試應用程序到目前爲止完全按照預期工作,所以我非常肯定這不是Zxing或我的用戶控件。

任何幫助,建議將不勝感激,或者如果你需要我提供額外的信息,請讓我知道什麼,我會盡量提供它。

謝謝。

+0

這可能是一個與.NET Native編譯代碼相關的問題嗎?您是否嘗試過使用「編譯.NET本地工具鏈」進行調試? – Plac3Hold3r

+0

嗨,我已經試過了,我也嘗試過與'優化代碼'選中,並仍然不會在調試模式下崩潰。 – Thierry

回答

0

那麼,這是一項艱苦的練習,並且浪費我的時間!

這是下降到幾件事情!

  1. 我在Release模式下使用了一個不同的DataService,它沒有實現。通過實施,我的意思是我所有的功能都返回NotImplementedExceptionnull值。

  2. 將我的模型傳遞給ViewModel時,我沒有檢查它是否爲空,從而導致未處理的exceptions

  3. 我有一連串的mvvmlight事件(Messenger.Default.Send <>)被觸發,沒有人檢查錯誤或空值。

雖然所有這些都是由我的驗證不好造成的,但在Release模式下這些錯誤報告極其糟糕!如果從頭開始,我收到了一個N​​ullReferenceException異常或任何類型的異常,它會立即讓我朝着正確的方向發展,但拋出像我一樣的錯誤是完全沒用的,但它並沒有得到教訓!

我只能說,如果這個問題發生在你身上,不要浪費你的時間重寫代碼或試圖找到解決方法。首先按照您的工作流程/事件鏈進行工作,並希望最終抓到罪魁禍首。

希望這會有所幫助。

+0

嗨,我的應用程序有同樣的問題。 上次(如6個月前),我卸載了應用程序,重新啓動,並再次安裝,一切正常。 所以我不認爲你或我的修復這是一個真正的解決方案。 現在我再次出現錯誤,但我不想像上次那樣嘗試重新安裝,我想先排除錯誤。 那時候,我讀到ddl的錯誤可能是由系統端的大量問題引起的,無法讀取dll文件。或者 - 似乎是我的情況,在註冊表中出現了一些混亂的引用,因爲我需要訪問圖片目錄。 –

+0

那麼,你有沒有再次遇到這個問題,並以另一種方式修復它? –

0

不幸的是,我們遇到了類似的問題,我們涉及到在應用程序中設置更改本地化的限定符值,但提出了神祕失敗快速/ SharedLibrary本機錯誤。將Microsoft.NETCore.UniversalWindowPlatform包從6.0.4升級到6.0.7似乎解決了這個問題。

只是想到這個,因爲我正在研究這個錯誤的另一個地方涉及到通過升級他們的NETCore包來解決SharedLibrary問題,這種情況是早期的(5.x),但是認爲它值得一試。

相關問題