我有一个带有 WinUI 2.0 树视图控件的 UWP Windows 商店应用程序。我根据用户选择的文件夹在树视图中加载子目录结构。
我面临的问题是当我在我的开发机器上选择某些文件夹时应用程序崩溃。它适用于其他文件夹。我可以在 Windows 存储诊断数据中看到与我的一些应用程序用户相同的崩溃。
这里是我机器的调用堆栈,用于崩溃:
Unhandled exception thrown: read access violation.
this->m_strongHost.ptr_ was nullptr.
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::CacheManager::InitCollectionsCache() Line 787
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_cachemanager_partial.cpp(787)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::CacheManager::GetItem(int indexInItemCollection, IInspectable * * ppItem) Line 868
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_cachemanager_partial.cpp(868)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::GenerateContainerAtIndexImpl(int indexInItemCollection, Windows::UI::Xaml::IUIElement * * ppReturnValue) Line 189
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_iicg2_partial.cpp(189)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanelGenerated::GenerateContainerAtIndex(int index, Windows::UI::Xaml::IUIElement * * ppReturnValue) Line 567
at onecoreuap\windows\dxaml\xcp\dxaml\lib\winrtgeneratedclasses\moderncollectionbasepanel.g.cpp(567)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::Generate(DirectUI::ModernCollectionBasePanel::CollectionIterator iterator, Windows::UI::Xaml::Controls::LayoutReference referenceInformation, unsigned char goForward) Line 1374
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(1374)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::RunGenerate() Line 902
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(902)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::RunVirtualization() Line 628
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(628)
Windows.UI.Xaml.dll!DirectUI::ModernCollectionBasePanel::MeasureOverride(Windows::Foundation::Size availableSize, Windows::Foundation::Size * pReturnValue) Line 521
at onecoreuap\windows\dxaml\xcp\dxaml\lib\moderncollectionbasepanel_partial.cpp(521)
Windows.UI.Xaml.dll!DirectUI::FrameworkElementGenerated::MeasureOverrideProtected(Windows::Foundation::Size availableSize, Windows::Foundation::Size * pReturnValue) Line 1056
at onecoreuap\windows\dxaml\xcp\dxaml\lib\winrtgeneratedclasses\frameworkelement.g.cpp(1056)
Windows.UI.Xaml.dll!DirectUI::FrameworkElement::MeasureOverrideFromCore(CFrameworkElement * nativeTarget, float inWidth, float inHeight, float * outWidth, float * outHeight) Line 255
at onecoreuap\windows\dxaml\xcp\dxaml\lib\frameworkelement_partial.cpp(255)
[Inline Frame] Windows.UI.Xaml.dll!CFxCallbacks::FrameworkElement_MeasureOverride(CFrameworkElement *) Line 844
at onecoreuap\windows\dxaml\xcp\dxaml\lib\fxcallbacks.cpp(844)
Windows.UI.Xaml.dll!CFrameworkElement::MeasureCore(XSIZEF availableSize, XSIZEF & desiredSize) Line 1597
at onecoreuap\windows\dxaml\xcp\core\core\elements\framework.cpp(1597)
Windows.UI.Xaml.dll!CUIElement::MeasureInternal(XSIZEF availableSize) Line 4121
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4121)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 3981
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(3981)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CUIElement::Measure(XSIZEF availableSize) Line 4031
at onecoreuap\windows\dxaml\xcp\core\core\elements\uielement.cpp(4031)
Windows.UI.Xaml.dll!CLayoutManager::UpdateLayout(unsigned int controlWidth, unsigned int controlHeight) Line 279
at onecoreuap\windows\dxaml\xcp\core\layout\layoutmanager.cpp(279)
Windows.UI.Xaml.dll!CCoreServices::NWDrawTree(HWWalk * pHWWalk, CWindowRenderTarget * pRenderTarget, VisualTree * pVisualTree, unsigned int forceRedraw, XRECT_WH * prcDirtyRect) Line 6354
at onecoreuap\windows\dxaml\xcp\core\dll\xcpcore.cpp(6354)
Windows.UI.Xaml.dll!CCoreServices::NWDrawMainTree(CWindowRenderTarget * pIRenderTarget, bool fForceRedraw, XRECT_WH * prcDirtyRect) Line 6078
at onecoreuap\windows\dxaml\xcp\core\dll\xcpcore.cpp(6078)
Windows.UI.Xaml.dll!CWindowRenderTarget::Draw(CCoreServices * fForceRedraw, unsigned int prcDirtyRect, XRECT_WH *) Line 136
at onecoreuap\windows\dxaml\xcp\core\compositor\windowrendertarget.cpp(136)
Windows.UI.Xaml.dll!CXcpBrowserHost::OnTick() Line 545
at onecoreuap\windows\dxaml\xcp\host\win\browserdesktop\winbrowserhost.cpp(545)
Windows.UI.Xaml.dll!CXcpDispatcher::Tick() Line 1449
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1449)
Windows.UI.Xaml.dll!CXcpDispatcher::OnReentrancyProtectedWindowMessage(HWND__ * msg, unsigned int lParam, unsigned __int64) Line 1041
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1041)
[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::ProcessMessage(HWND__ *) Line 890
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(890)
Windows.UI.Xaml.dll!CXcpDispatcher::WindowProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wParam, __int64 lParam) Line 839
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(839)
Windows.UI.Xaml.dll!CDeferredInvoke::DispatchQueuedMessage(bool * dispatchedWork, bool * hasMoreWork) Line 301
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(301)
[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::MessageTimerCallback() Line 1534
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1534)
Windows.UI.Xaml.dll!CXcpDispatcher::MessageTimerCallbackStatic(void * myUserData) Line 1526
at onecoreuap\windows\dxaml\xcp\win\shared\xcpwindow.cpp(1526)
CoreMessaging.dll!Microsoft__CoreUI__Dispatch__TimeoutHandler$CallbackThunk(class System::Delegate *)
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::TimeoutManager::Callback_OnDispatch()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_DoWork()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_WindowProc()
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchMessageWorker()
Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessMessage(bool bDrainQueue, bool * pbWindowMessagesProcessed, bool * pbInvokeItemProcessed) Line 320
at onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp(320)
Windows.UI.dll!Windows::UI::Core::CDispatcher::WaitAndProcessMessagesInternal(bool bRunAlwaysOnce, void * hEventWait) Line 1950
at onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp(1950)
Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessEvents(Windows::UI::Core::CoreProcessEventsOption options) Line 596
at onecoreuap\windows\advcore\winrt\onecoreiwindow\corewindow\common\dispatcher.cpp(596)
Windows.UI.Xaml.dll!CJupiterWindow::RunCoreWindowMessageLoop() Line 1234
at onecoreuap\windows\dxaml\xcp\dxaml\lib\jupiterwindow.cpp(1234)
[Inline Frame] Windows.UI.Xaml.dll!CJupiterControl::RunMessageLoop() Line 1065
at onecoreuap\windows\dxaml\xcp\dxaml\lib\jupitercontrol.cpp(1065)
Windows.UI.Xaml.dll!DirectUI::DXamlCore::RunMessageLoop() Line 2463
at onecoreuap\windows\dxaml\xcp\dxaml\lib\dxamlcore.cpp(2463)
twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run()
twinapi.appcore.dll!<lambda>(void)()
SHCore.dll!_WrapperThreadProc()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
如您所见,整个调用堆栈只有 Windows 系统功能,您知道如何继续吗?