question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0xC000027B exception when trying to start WinUI from within a dll

See original GitHub issue

Describe the bug Our exe (C++ desktop app) is (and must stay) UI agnostic. The UI is loaded from a C/C++ dll. The first exported function called from the exe is “void InitWinUI()” that mimic what is done in the main from the desktop c++ sample.

void InitWinUI()
{
	winrt::init_apartment(winrt::apartment_type::single_threaded);
	//winrt::init_apartment();
	print_context();

	::winrt::Microsoft::UI::Xaml::Application::Start(
		[](auto&&)
		{
			::winrt::make<::winrt::App1::implementation::App>();
		});
}

Exception 0xC000027B is thrown somewhere within the call to “winrt::Microsoft::UI::Xaml::Application::Start(lambda)” Tried with winui preview1 and preview2. Same result.

Steps to reproduce the bug Make a C++ winui desktop app using the winui sample (VS new project) Change its type to dll, and export a basic C function “InitWInUI()” as above Make a regular C/C++ exe (console or , link it with the dll and call InitWinUI() -> notice the 0xC000027B exception

Expected behavior Able to “start” winui (create windows, controls, etc) from within a dll. Maybe I’m doing it wrong… Any workaround or suggestions welcome!

Screenshots Unhandled exception at 0x00007FFFA90E6589 (Microsoft.Internal.XamlUdk.dll) in GameFake.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x000001F9DFC377C0, 0x0000000000000001).

Version Info WinUI version=“3.0.0-preview2.200713.0” (same with preview1) CppWinRT version=“2.0.200316.3” VCRTForwarders.140 version=“1.0.6”

Windows 10 version 1909 (build 18363.900)

Desktop

Additional context I attach the mini dump file. Here is the callstack:

 	KernelBase.dll!RaiseFailFastException()	Unknown
 	combase.dll!RoFailFastWithErrorContextInternal2(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 1458	C++
 	Microsoft.Internal.XamlUdk.dll!FailFastWithStowedExceptionInfo()	Unknown
 	Microsoft.UI.Xaml.dll!UdkShim::FailFastWithStowedExceptions(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 85	C++
 	Microsoft.UI.Xaml.dll!FailFastWithStowedExceptions(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 93	C++
 	Microsoft.UI.Xaml.dll!CXcpDispatcher::Init(IXcpHostSite * pSite) Line 356	C++
 	Microsoft.UI.Xaml.dll!CXcpDispatcher::Create(IXcpHostSite * pSite, IXcpDispatcher * * ppInterface) Line 505	C++
 	Microsoft.UI.Xaml.dll!CJupiterControl::Init() Line 145	C++
 	Microsoft.UI.Xaml.dll!CJupiterControl::Create(CJupiterControl * * ppControl) Line 32	C++
 	Microsoft.UI.Xaml.dll!DirectUI::DXamlCore::InitializeInstance(InitializationType initializationType, bool runWithoutCoreApplication) Line 372	C++
 	Microsoft.UI.Xaml.dll!DirectUI::DXamlCore::InitializeImpl(InitializationType initializationType, bool runWithoutCoreApplication) Line 2636	C++
 	Microsoft.UI.Xaml.dll!DirectUI::FrameworkApplication::StartDesktop() Line 188	C++
 	Microsoft.UI.Xaml.dll!DirectUI::FrameworkApplicationFactory::Start(ABI::Microsoft::UI::Xaml::IApplicationInitializationCallback * pCallback) Line 713	C++
>	App1.dll!winrt::impl::consume_Microsoft_UI_Xaml_IApplicationStatics<winrt::Microsoft::UI::Xaml::IApplicationStatics>::Start(const winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback & callback) Line 260	C++
 	App1.dll!winrt::Microsoft::UI::Xaml::Application::Start::__l2::<lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics & f) Line 12898	C++
 	App1.dll!winrt::impl::factory_cache_entry<winrt::Microsoft::UI::Xaml::Application,winrt::Microsoft::UI::Xaml::IApplicationStatics>::call<void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &) &>(winrt::Microsoft::UI::Xaml::Application::Start::__l2::void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &) & callback) Line 5984	C++
 	App1.dll!winrt::impl::call_factory<winrt::Microsoft::UI::Xaml::Application,winrt::Microsoft::UI::Xaml::IApplicationStatics,void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &)>(winrt::Microsoft::UI::Xaml::Application::Start::__l2::void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &) && callback) Line 6007	C++
 	App1.dll!winrt::Microsoft::UI::Xaml::Application::Start(const winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback & callback) Line 12899	C++
 	App1.dll!InitWinUI() Line 48	C++
 	GameFake.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 34	C++
 	GameFake.exe!invoke_main() Line 123	C++
 	GameFake.exe!__scrt_common_main_seh() Line 288	C++
 	GameFake.exe!__scrt_common_main() Line 331	C++
 	GameFake.exe!wWinMainCRTStartup() Line 17	C++
 	kernel32.dll!BaseThreadInitThunk()	Unknown
 	ntdll.dll!RtlUserThreadStart()	Unknown

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
willyntcommented, Jul 21, 2020

@stevenbrix thx for the suggestions, I’ll give it a go.

Our app/exe is a game, which in normal mode doesn’t need UI. Started with a specific parameter, it runs in “tool/editor” mode, which loads the “UI” dll and add dialogs/controls, etc… UI dll is currently MFC based. I’m investigating replacing MFC by Winui3 (progressively).

0reactions
github-actions[bot]commented, Jul 29, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Faulting Module: microsoft.ui.xaml.dll - Microsoft Q&A
When I'm trying to run my WinUI 3 app, I get this error in Event Viewer: Log Name: Application Source: Application Error Date:...
Read more >
Application-internal exception in Windows.UI.Xaml.dll
Xaml.dll) in appname.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x127DC468, 0x00000005).' The crash occurs ...
Read more >
Adding DevExpress WinUI to existing project
Unhandled exception at 0x00007FFD49C6BE3E (KernelBase.dll) in AppWinUi3DxTest.exe: 0xC000027B: An application-internal exception has occurred ( ...
Read more >
Windows apps have begun crashing after MFA ...
I had an issue like this where UWP apps all immediately crashed because the .net native package in my system image was not...
Read more >
Windows.UI.Xaml Exception - Developer Community
The Exception was: Unhandled exception at 0x00007FFD287D3530 (Windows.UI.Xaml.dll) in Sentry.UWP.exe: 0xC000027B: An application-internal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found