smourier/WinUI3Cpp

Unhandled Exception in Cloned Code

Opened this issue · 2 comments

Simon, Thanks for providing this sample. I'm hoping to implement a TreeView, so it's exactly what I need. Unfortunately, I'm getting an error:
'''
Unhandled exception at 0x00007FFA0562FABC in TreeViewSample.exe: Microsoft C++ exception: winrt::hresult_class_not_registered at memory location 0x0000000880AFEE68.
'''
All I did was clone your code, compile it in Debug mode (VS 2022 17.11.2), and run. Here's the call stack:

''' KernelBase.dll!00007ffa0562fabc() Unknown
vcruntime140d.dll!00007ff930c29362() Unknown

TreeViewSample.exe!winrt::throw_hresult(const winrt::hresult result) Line 5135 C++
TreeViewSample.exe!winrt::check_hresult(const winrt::hresult result) Line 5233 C++
TreeViewSample.exe!winrt::get_activation_factorywinrt::Microsoft::UI::Xaml::IApplicationStatics(const winrt::param::hstring & name) Line 6293 C++
TreeViewSample.exe!winrt::impl::factory_cache_entrywinrt::Microsoft::UI::Xaml::Application,winrt::Microsoft::UI::Xaml::IApplicationStatics::call<void (const winrt::Microsoft::UI::Xaml::IApplicationStatics &) &>(winrt::Microsoft::UI::Xaml::Application::Start::__l2::void (const winrt::Microsoft::UI::Xaml::IApplicationStatics &) & callback) Line 6543 C++
TreeViewSample.exe!winrt::impl::call_factory<winrt::Microsoft::UI::Xaml::Application,winrt::Microsoft::UI::Xaml::IApplicationStatics,void (const winrt::Microsoft::UI::Xaml::IApplicationStatics &)>(winrt::Microsoft::UI::Xaml::Application::Start::l2::void (const winrt::Microsoft::UI::Xaml::IApplicationStatics &) && callback) Line 6587 C++
TreeViewSample.exe!winrt::Microsoft::UI::Xaml::Application::Start(const winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback & callback) Line 12441 C++
TreeViewSample.exe!wWinMain(HINSTANCE
* formal, HINSTANCE * __formal, wchar_t * __formal, int __formal) Line 69 C++
TreeViewSample.exe!invoke_main() Line 123 C++
TreeViewSample.exe!__scrt_common_main_seh() Line 288 C++
TreeViewSample.exe!__scrt_common_main() Line 331 C++
TreeViewSample.exe!wWinMainCRTStartup(void * __formal) Line 17 C++
kernel32.dll!00007ffa071c257d() Unknown
ntdll.dll!00007ffa07d4af28() Unknown
'''
I'm still low on the C++/WinRT + WinUI 3 learning curve, so I have no clue how to fix this. TIA

I just went through the project settings and found that the C++ Language Standard was set to an older version. When I updated to Preview, the program started working. Issue solved.

Hi,

I just retried the project as is and it worked fine (I'm also on VS 2022 17.11.2). C++ language standard is set to "ISO C++17 Standard (/std:c++17)".

However your error "winrt::hresult_class_not_registered" looks much like something else (WinRT class activation that failed).

Strange, not sure what's the root cause of your problem. I've just updated the nuget packages too though...