Share via

UWP app System.IO.FileLoadException: 'Could not find or load a specific file. (Exception from HRESULT: 0x80131621)'

Hong 1,526 Reputation points
2026-05-06T13:02:06.09+00:00

When I run a UWP app in debugging mode, it always throws this exception at the start:

System.IO.FileLoadException
  HResult=0x80131621
  Message=Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
  Source=System.Private.CoreLib
  StackTrace:
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type, ObjectHandleOnStack keepalive)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)


It does not seem to affect the app, so it is just a minor nuisance that I would like to get rid of.

It is thrown at the following method in XamlTypeInfo.g.cs:

        public global::Windows.UI.Xaml.Markup.IXamlType GetXamlTypeByName(string typeName)
        {
            return Provider.GetXamlType(typeName);
        }

Is there a way to get rid of it?

Developer technologies | Universal Windows Platform (UWP)

Answer accepted by question author

Jay Pham (WICLOUD CORPORATION) 3,690 Reputation points Microsoft External Staff Moderator
2026-05-07T03:44:59.1666667+00:00

Hello @Hong ,

I see this is most likely a first-chance exception that the debugger catches the runtime handles it internally, which is why the app continues to work fine.

To stop it from breaking into the debugger:

  • Press Ctrl+Alt+E to open Exception Settings.
  • Find System.IO.FileLoadException under Common Language Runtime Exceptions.
  • Uncheck it.

Could you also confirm whether the exception appears only in Debug, or also in a Release build with .NET Native enabled? If it shows up in Release, the fix is different it would involve adding a runtime directive to .rd.xml, and I can help with that.

Hope this helps! If my explanation and information I provided were useful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AI answer

    2026-05-06T13:02:20.81+00:00

    The exception is raised because the UWP XAML infrastructure is trying to resolve a type name at runtime (via reflection) and fails to load the corresponding implementation, even though the app continues to run. This is a tooling/runtime artifact and should not be handled with a try/catch in app code.

    For .NET Native–compiled UWP apps, such issues are typically caused by missing runtime artifacts or metadata that the reflection-based XAML infrastructure expects to find. These are controlled by the .rd.xml runtime directives file. When a type or member is referenced only dynamically (for example, by name), the .NET Native toolchain may remove its implementation unless explicitly preserved.

    To eliminate the exception instead of ignoring it:

    1. Identify which type name is being resolved when the exception occurs (from the debugger or call stack around GetXamlTypeByName).
    2. Add an appropriate runtime directive in the app’s .rd.xml file to preserve that type (or its containing namespace) with Activate or Dynamic policy so that both metadata and implementation are kept at runtime.
    3. Rebuild and redeploy the app, then repeat until no further missing-runtime-artifact or metadata-related exceptions appear.

    When adding directives, prefer specifying them at the namespace or type level (instead of individual members) to keep the app resilient to future code changes, at the cost of slightly larger binaries and longer compile times.

    Do not try to “handle away” this exception in code; it indicates that the runtime has removed implementation code that XAML/reflection expects. The correct fix is to adjust the .rd.xml configuration so the required implementation is preserved.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.