<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rafael Ruiz Coutiño</title>
    <description>The latest articles on DEV Community by Rafael Ruiz Coutiño (@zhazkuat_bug).</description>
    <link>https://dev.to/zhazkuat_bug</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4214479%2F043b07a0-e247-4b48-b482-972123e9082d.jpeg</url>
      <title>DEV Community: Rafael Ruiz Coutiño</title>
      <link>https://dev.to/zhazkuat_bug</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zhazkuat_bug"/>
    <language>en</language>
    <item>
      <title>WinUI 3 Startup Crash (0xC000027B): How We Fixed a Missing resources.pri</title>
      <dc:creator>Rafael Ruiz Coutiño</dc:creator>
      <pubDate>Thu, 29 Oct 2026 06:48:30 +0000</pubDate>
      <link>https://dev.to/zhazkuat_bug/winui-3-startup-crash-0xc000027b-how-we-fixed-a-missing-resourcespri-4hjj</link>
      <guid>https://dev.to/zhazkuat_bug/winui-3-startup-crash-0xc000027b-how-we-fixed-a-missing-resourcespri-4hjj</guid>
      <description>&lt;p&gt;WinUI 3 Startup Crash (0xC000027B): How We Fixed a Missing resources.pri&lt;/p&gt;

&lt;p&gt;A real-world debugging case involving Windows App SDK, unpackaged applications, and self-contained deployment.&lt;/p&gt;

&lt;p&gt;During the development of a WinUI 3 desktop application, we encountered a persistent startup failure.&lt;/p&gt;

&lt;p&gt;The application terminated unexpectedly before displaying its user interface. The diagnostic logs pointed to Microsoft.UI.Xaml.dll, with the exception code 0xC000027B.&lt;/p&gt;

&lt;p&gt;Initially, this appeared to be a runtime issue, a version incompatibility, or an internal XAML initialization failure.&lt;/p&gt;

&lt;p&gt;After several controlled experiments, however, we discovered something different: the application was building successfully, but the publishing process was not correctly generating the resource index required at runtime.&lt;/p&gt;

&lt;p&gt;We are sharing this investigation because other developers may encounter similar symptoms.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Symptoms&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Our environment used WinUI 3, Windows App SDK, and an unpackaged, self-contained, x64 deployment model.&lt;/p&gt;

&lt;p&gt;During the investigation, we encountered several error codes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0xC000027B&lt;/li&gt;
&lt;li&gt;0x80004005&lt;/li&gt;
&lt;li&gt;0x80070002&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The process could terminate within:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft.UI.Xaml.dll&lt;/li&gt;
&lt;li&gt;Microsoft_UI_Xaml!FailFastWithStowedExceptions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In one of our diagnostic experiments, the failure occurred while constructing:&lt;/p&gt;

&lt;p&gt;Microsoft.UI.Xaml.Controls.XamlControlsResources&lt;/p&gt;

&lt;p&gt;We also encountered the following error message:&lt;/p&gt;

&lt;p&gt;Cannot find a resource with the given key: AcrylicBackgroundFillColorDefaultBrush&lt;/p&gt;

&lt;p&gt;These symptoms do not necessarily share a single underlying cause.&lt;/p&gt;

&lt;p&gt;In our case, however, they provided important clues that eventually led us to a resource resolution problem.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, We Isolated the Application from the Framework&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of continuing to modify the entire application, we created minimal diagnostic probes to identify the first operation that failed.&lt;/p&gt;

&lt;p&gt;The results were revealing:&lt;/p&gt;

&lt;p&gt;Stage   Result&lt;br&gt;
Runtime initialization  PASS&lt;br&gt;
Application creation    PASS&lt;br&gt;
Basic XAML component creation   PASS&lt;br&gt;
XamlControlsResources construction  FAIL&lt;br&gt;
Empty resource dictionary   PASS&lt;br&gt;
Minimal window without the problematic initialization path  PASS&lt;/p&gt;

&lt;p&gt;This investigation allowed us to reproduce the failure without loading the original application’s business logic.&lt;/p&gt;

&lt;p&gt;That distinction was essential because it significantly narrowed the search space.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Common Trap: Testing Different Versions Does Not Mean Loading Different Runtimes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We also investigated whether the failure depended on a specific Windows App SDK version.&lt;/p&gt;

&lt;p&gt;Several experiments requested different minimum runtime versions.&lt;/p&gt;

&lt;p&gt;However, when we inspected the DLL actually loaded by the process, we discovered that the different configurations ultimately resolved to the same physical version of Microsoft.UI.Xaml.dll.&lt;/p&gt;

&lt;p&gt;This led to an important conclusion:&lt;/p&gt;

&lt;p&gt;Changing the requested runtime version does not prove that a different runtime is actually being executed.&lt;/p&gt;

&lt;p&gt;In environments that use dynamic dependencies, developers must verify both the selected runtime package and the actual DLLs loaded by the process.&lt;/p&gt;

&lt;p&gt;Otherwise, what appears to be a comparison between multiple runtime versions may simply be repeated testing against the same runtime.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Breakthrough: resources.pri&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The decisive discovery came when we examined the build and publishing pipeline.&lt;/p&gt;

&lt;p&gt;The build process generated an application-specific PRI resource index, but the published output did not correctly contain the expected root file:&lt;/p&gt;

&lt;p&gt;resources.pri&lt;/p&gt;

&lt;p&gt;With the resource map:&lt;/p&gt;

&lt;p&gt;Application&lt;/p&gt;

&lt;p&gt;In other words, generating resources during compilation was not enough.&lt;/p&gt;

&lt;p&gt;The publishing process also needed to produce and deliver the correct resource index in the expected location.&lt;/p&gt;

&lt;p&gt;To verify this, we performed a controlled comparison.&lt;/p&gt;

&lt;p&gt;Test A: Without the correct PRI&lt;/p&gt;

&lt;p&gt;Resource resolution failed, and the application could not complete startup initialization.&lt;/p&gt;

&lt;p&gt;Test B: With the correct PRI included&lt;/p&gt;

&lt;p&gt;Resource resolution succeeded, and the application started successfully.&lt;/p&gt;

&lt;p&gt;Test C: Removing only resources.pri&lt;/p&gt;

&lt;p&gt;The resource resolution failure returned.&lt;/p&gt;

&lt;p&gt;Test D: Restoring the correct published output&lt;/p&gt;

&lt;p&gt;The application started working again.&lt;/p&gt;

&lt;p&gt;These experiments provided much stronger causal evidence than simply observing exception code 0xC000027B.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Fix: Integrating MakePri into the Publish Pipeline&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The solution was to integrate PRI generation into the reproducible publishing process.&lt;/p&gt;

&lt;p&gt;The tool we used was:&lt;/p&gt;

&lt;p&gt;MakePri.exe&lt;/p&gt;

&lt;p&gt;Microsoft documents this mechanism for unpackaged applications that need to generate an appropriate resources.pri file.&lt;/p&gt;

&lt;p&gt;The general generation pattern is:&lt;/p&gt;

&lt;p&gt;makepri.exe new &lt;code&gt;&lt;br&gt;
  /pr "&amp;lt;RESOURCE_DIRECTORY&amp;gt;"&lt;/code&gt;&lt;br&gt;
  /cf "" &lt;code&gt;&lt;br&gt;
  /in Application&lt;/code&gt;&lt;br&gt;
  /of "\resources.pri" `&lt;br&gt;
  /o&lt;/p&gt;

&lt;p&gt;Illustrative example: directories and configuration must be adapted to the specific project.&lt;/p&gt;

&lt;p&gt;In our case, the essential changes were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Integrating PRI generation into the MSBuild publishing process.&lt;/li&gt;
&lt;li&gt;Using an appropriate MakePri configuration for the unpackaged deployment model.&lt;/li&gt;
&lt;li&gt;Omitting the  section from that configuration.&lt;/li&gt;
&lt;li&gt;Enabling the necessary PRI indexer to include resources from referenced dependencies.&lt;/li&gt;
&lt;li&gt;Generating the root resource map named Application.&lt;/li&gt;
&lt;li&gt;Placing resources.pri alongside the published executable.&lt;/li&gt;
&lt;li&gt;Ensuring that both application resources and WinUI resources remained accessible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We did not need to reinstall Windows App SDK, modify packages inside WindowsApps, or manually copy files from an installed runtime.&lt;/p&gt;

&lt;p&gt;The fix became part of the build and publishing process rather than depending on manual intervention after publication.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An Additional Safeguard: Preventing Stale PRI Files&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The initial fix allowed the application to start, but we identified another potential risk.&lt;/p&gt;

&lt;p&gt;What happens if a previous publication leaves behind a valid resources.pri file and a subsequent MakePri execution fails?&lt;/p&gt;

&lt;p&gt;A poorly controlled publishing process could retain the old file and incorrectly appear to have succeeded.&lt;/p&gt;

&lt;p&gt;To prevent this, we added a safeguard that ensures a residual PRI file cannot be accepted as newly generated output.&lt;/p&gt;

&lt;p&gt;We validated this behavior through specific tests:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Successful clean publication.&lt;/li&gt;
&lt;li&gt;Publication with an existing PRI file.&lt;/li&gt;
&lt;li&gt;Deliberate MakePri failure.&lt;/li&gt;
&lt;li&gt;Recovery followed by a clean publication.&lt;/li&gt;
&lt;li&gt;Regression testing against previously working behavior.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The publishing process correctly rejected the MakePri failure and did not accept the outdated file as a newly generated artifact.&lt;/p&gt;

&lt;p&gt;This protection is particularly important in automated publishing pipelines, especially when output directories are reused.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How We Verified the Fix&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We did not consider a successful build exit code sufficient evidence that the problem had been resolved.&lt;/p&gt;

&lt;p&gt;We also inspected the physical published output and verified the application’s runtime behavior.&lt;/p&gt;

&lt;p&gt;Our validation included:&lt;/p&gt;

&lt;p&gt;Verification    Result&lt;br&gt;
Two clean publishing runs   PASS&lt;br&gt;
Automatically generated PRI index   PASS&lt;br&gt;
Reproducible results    PASS&lt;br&gt;
Root resource map: Application  PASS&lt;br&gt;
Application resources   PASS&lt;br&gt;
WinUI resources PASS&lt;br&gt;
Executable startup  PASS&lt;br&gt;
Main window visible PASS&lt;br&gt;
Normal process shutdown PASS&lt;br&gt;
Remaining processes 0&lt;br&gt;
New events matching the investigated failure    None detected&lt;/p&gt;

&lt;p&gt;We also used MakePri to inspect the generated indexes:&lt;/p&gt;

&lt;p&gt;makepri.exe dump &lt;code&gt;&lt;br&gt;
  /if "&amp;lt;PUBLISH_DIRECTORY&amp;gt;\resources.pri"&lt;/code&gt;&lt;br&gt;
  /of "\resources.xml"&lt;/p&gt;

&lt;p&gt;This allowed us to examine the actual contents of the resource index instead of assuming that a file named resources.pri was necessarily valid.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What We Learned&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This incident provided several lessons that may be useful in other WinUI 3 projects.&lt;/p&gt;

&lt;p&gt;Lesson 1: An exception inside Microsoft.UI.Xaml.dll does not automatically indicate a Microsoft framework defect.&lt;/p&gt;

&lt;p&gt;The framework may simply be where an underlying resource or deployment problem becomes visible.&lt;/p&gt;

&lt;p&gt;Lesson 2: Build, publish, and runtime are separate stages.&lt;/p&gt;

&lt;p&gt;A project can compile successfully while still producing an incomplete deployment.&lt;/p&gt;

&lt;p&gt;Lesson 3: PRI structure matters in unpackaged applications.&lt;/p&gt;

&lt;p&gt;The presence, location, and structure of the resource index can be critical to successful resource resolution.&lt;/p&gt;

&lt;p&gt;Lesson 4: Runtime version comparisons require verification.&lt;/p&gt;

&lt;p&gt;Requesting different Windows App SDK versions does not guarantee that different binaries are actually being loaded.&lt;/p&gt;

&lt;p&gt;Lesson 5: Negative tests are extremely valuable.&lt;/p&gt;

&lt;p&gt;Removing a single dependency, reproducing the failure, and restoring that dependency can establish causal relationships that diagnostic logs alone may not reveal.&lt;/p&gt;

&lt;p&gt;Lesson 6: Reproducible fixes belong in the pipeline.&lt;/p&gt;

&lt;p&gt;Manually copying a missing file may be useful as a diagnostic experiment, but it should not become a hidden requirement for successful deployment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What to Check If You Encounter a Similar Failure&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If your unpackaged WinUI 3 application crashes during XAML resource initialization, consider checking the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the required bootstrap or runtime initialization complete successfully for your deployment model?&lt;/li&gt;
&lt;li&gt;Can the failure be reproduced in a minimal application with valid XAML initialization?&lt;/li&gt;
&lt;li&gt;Which physical version of Microsoft.UI.Xaml.dll is actually loaded by the process?&lt;/li&gt;
&lt;li&gt;Does the published output contain resources.pri?&lt;/li&gt;
&lt;li&gt;Does the resource index contain the correct root map for your deployment scenario?&lt;/li&gt;
&lt;li&gt;Can both application resources and referenced dependency resources be resolved?&lt;/li&gt;
&lt;li&gt;Does MakePri execute during publication, and are its failures correctly propagated?&lt;/li&gt;
&lt;li&gt;Does removing only the resource index reproduce the failure in an isolated negative test?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We do not recommend copying files from WindowsApps, modifying installed runtimes, or randomly switching SDK versions before isolating the actual defect.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;In our case, resolving the startup failure did not require changes to the application’s core logic.&lt;/p&gt;

&lt;p&gt;The operational root cause was an incomplete PRI resource index integration within the unpackaged publishing process.&lt;/p&gt;

&lt;p&gt;Once we correctly generated resources.pri using MakePri and included it in the published application, startup worked again.&lt;/p&gt;

&lt;p&gt;The main takeaway is straightforward:&lt;/p&gt;

&lt;p&gt;When WinUI 3 fails during resource initialization, do not investigate only your XAML code or runtime version. Inspect what your publishing pipeline is actually producing.&lt;/p&gt;

&lt;p&gt;This is a specific debugging case, not a universal explanation for error 0xC000027B.&lt;/p&gt;

&lt;p&gt;Other applications may encounter the same exception code for entirely different reasons.&lt;/p&gt;

&lt;p&gt;Official Documentation and References&lt;/p&gt;

&lt;p&gt;For additional technical background, refer to Microsoft Learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Localization and resources for unpackaged applications&lt;/li&gt;
&lt;li&gt;MRT Core and PRI resource files&lt;/li&gt;
&lt;li&gt;Self-contained deployment with Windows App SDK&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We hope this experience helps other developers identify a problem that, at first glance, can appear considerably more complex than it actually is.&lt;/p&gt;

</description>
      <category>windows</category>
      <category>debugging</category>
      <category>winui</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
