Reputation: 413
I am trying to log all unexpected exceptions in my .NET Core App. I have set up Sentry in my exception handling middleware. when i try and log the exception message using SentrySDK.CapetureMessage(e.Message), it works and shows up in the sentry dashboard. However when i try to log the actual exception using SentrySDK.CapetureException(e) it doesnt log anything and throws an error:
fail: Sentry.ISentryClient[0]
An error occurred when capturing the event System.IO.FileLoadException: Could not load file or assembly 'System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=xx'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=xx'
Weirdly enough, the exceptions do get logged when i call SentrySDK.CapetureException(e) outside of my Middleware exception handler. Been stuck on this a while, any help would be appreciated.
Upvotes: 2
Views: 1932
Reputation: 2621
This is a reported regression that was introduced some time after version 3.3.4 (most likely 3.4.0) of Sentry's .NET SDK, which only affects projects targeting .NET Core 3.0 or 3.1.
Here's a GitHub issue tracking the bug: https://github.com/getsentry/sentry-dotnet/issues/1050
For now, the best workaround is to downgrade to version 3.3.4 of Sentry SDK. We will try to fix the issue as soon as possible. Sorry for the inconvenience!
Update: this should now be fixed in latest version (v3.6.0).
Upvotes: 4
Reputation: 6408
A work around is to add the dependency directly to your project:
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" />
Upvotes: 1