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.

SentrySdk.Init fails with System.Reflection.MissingMetadataException in release mode

See original GitHub issue

Package

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

  1. Create an UWP app and initialize the sentry SDK as specified in the documentation
  2. 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:open
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
epaezrubiocommented, Nov 4, 2022

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:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <Namespace Name="Sentry" Serialize="Required All" />
  </Application>
</Directives>

This fixed the problem.

PS: Thank you also for the update regarding OnSuspending too, I adapted on my side too 😃

0reactions
mattjohnsonpintcommented, Feb 23, 2023

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 adding System.Text.Json to the runtime directives would help here also. See https://github.com/mattjohnsonpint/TimeZoneNames/issues/92

Read more comments on GitHub >

github_iconTop 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 >

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