Issue
When running my MAUI application on Windows after integrating Sentry, I receive the following error:
FileNotFoundException: Could not load file or assembly 'WinRT.Runtime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=****************'. The system cannot find the specified file.
I have tried searching for and adding the WinRT.Runtime package, but it does not appear in the NuGet package manager. My MAUI application hasn’t required this package before, so I’m wondering if this is an expected requirement for using Sentry on Windows or if it could be a compatibility issue.
Applies To
- All SaaS Customers and Self-Hosted Users
- SDK setup
- MAUI
Symptoms
I have previously applied a workaround on Visual Studio 17.11.5 due to a previous conflict with SkiaSharp and this version of Visual Studio.
Resolution
If the workaround looked something like the following:
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'"> <!--https://github.com/dotnet/maui/issues/25160--> <CsWinRTRcwFactoryFallbackGeneratorForceOptOut>true</CsWinRTRcwFactoryFallbackGeneratorForceOptOut> <WindowsSdkPackageVersion>10.0.19041.34</WindowsSdkPackageVersion> </PropertyGroup>
The setting WindowsSdkPackageVersion 10.0.19041.34 caused an older version of WinRT.Runtime (below 2.1) to be used, while Sentry requires version 2.1 or higher. SkiaSharp has now released a beta NuGet package that addresses the original issue, so removing the workaround should allow Sentry to function correctly.
If you are still experiencing issues, please don't hesitate to contact Sentry support.