SentrySdk.Init fails with System.Reflection.MissingMetadataException in release mode
See original GitHub issuePackage
Sentry
.NET Flavor
.NET Core
.NET Version
6.0.0
OS
Windows
SDK Version
3.23.1 (latest)
Self-Hosted Sentry Version
No response
Steps to Reproduce
- Create an UWP app and initialize the sentry SDK as specified in the documentation
- Run the app in Release mode
Expected Result
No crashes
Actual Result
An exception is thrown at Sentry.dll!Sentry.SentrySdk.InitHub(Sentry.SentryOptions options) Line 62
System.Reflection.MissingMetadataException
HResult=0x80131543
Message=This operation cannot be carried out because metadata for the following object was removed for performance reasons:\n\n EETypeRva:0x00050780\n\nNo further information is available. Rebuild in debug mode for better information.\n\n
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
If the application is run in Debug mode, this error is not triggered.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
System.Reflection.MissingRuntimeArtifactException
This works when the app was not compiled to the .NET Native tool chain (i.e. when running in debug mode). However, when compiling...
Read more >NET C# - does not report to the backend - SDKs
I have just implemented Sentry in my .NET application. When I run it from a console application it works fine and it reports...
Read more >[UWP] Exception on start with Release mode
My UWP Xamarin Forms app crashes on startup ("Release-Mode") with the message: Unhandled exception at 0x7650A6E2 (KernelBase.dll) in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your quick response. I was unaware of the “Compile with .NET Native tool chain” flag.
In case it may help anybody, I used the Runtime Directive builder tool in order to generate the following
Default.rd.xml
:This fixed the problem.
PS: Thank you also for the update regarding
OnSuspending
too, I adapted on my side too 😃This came up on another project of mine, and the culprit was
System.Text.Json
. Sentry uses that as well, so it’s possible that addingSystem.Text.Json
to the runtime directives would help here also. See https://github.com/mattjohnsonpint/TimeZoneNames/issues/92