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 v3 not working in VB .NET

See original GitHub issue

Please mark the type framework used:

  • ASP.NET MVC
  • ASP.NET Web API (OWIN)
  • ASP.NET Core
  • WPF
  • WinForms
  • Xamarin
  • Other:

Please mark the type of the runtime used:

  • .NET Framework
  • Mono
  • .NET Core
  • Version: 4.8

Please mark the NuGet packages used:

  • Sentry
  • Sentry.Serilog
  • Sentry.NLog
  • Sentry.Log4Net
  • Sentry.Extensions.Logging
  • Sentry.AspNetCore
  • Version: 2.1.8 & 3.7

I’m currently initializing SentrSDK 2.1.8 in VB .NET the following way:

Imports Sentry

Module mod_Main

    Sub Main()

        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)

        FrmSplash = New SplashScreen
        FrmSplash.Show()
        FrmSplash.Refresh()

        SentrySdk.Init("https://1111111@o22222.ingest.sentry.io/333333")

        frm_Main_Instance = New frm_Main
        Application.Run(frm_Main_Instance)
    End Sub

End Module

When I upgrade to SentrySDK 3.7, exceptions are not sent to Sentry.IO. I use the following test code:

        Try
            Throw New System.Exception("Testing.")
        Catch ex As Exception
            SentrySdk.CaptureException(ex)
        End Try

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nhinzevtcommented, Jul 14, 2021

I resolved the dependency issues using tips suggested here: https://stackoverflow.com/questions/42755274/visual-studio-2017-could-not-load-file-or-assembly-system-runtime-version-4

SentrySDK 3.8 now works correctly with VB.NET and the following initialization code:

        Dim options As New SentryOptions
        options.Dsn = "https://1111@2222.ingest.sentry.io/33333"
        options.Debug = True
        options.DiagnosticLogger = New ConsoleDiagnosticLogger(SentryLevel.Debug)
        SentrySdk.Init(options)

Updated log:

Debug: Using ‘GzipBufferedRequestBodyHandler’ body compression strategy with level Optimal. Debug: Initializing Hub for Dsn: ‘https://1111@2222.ingest.sentry.io/3333’. Debug: Registering integration: ‘AutoSessionTrackingIntegration’. Debug: Registering integration: ‘AppDomainUnhandledExceptionIntegration’. Debug: Registering integration: ‘AppDomainProcessExitIntegration’. Debug: Registering integration: ‘TaskUnobservedTaskExceptionIntegration’. Debug: Registering integration: ‘NetFxInstallationsIntegration’. Debug: New scope pushed. Before SentrySdk.CaptureMessage Info: Capturing event. Debug: Running main event processor on: Event 620db433f3474b7bb9b1b0e7782d434d Debug: No Exception and AttachStacktrace is off. No stack trace will be collected. Debug: Envelope queued up. After SentrySdk.CaptureMessage Debug: Envelope 620db433f3474b7bb9b1b0e7782d434d handed off to transport. #1 in queue. Before SentrySdk.CaptureException Exception thrown: ‘System.Exception’ in DB_GUI.exe Debug: Failed to report an error on a session because there is none active. Info: Capturing event. Debug: Running processor on exception: Testing. Debug: Creating SentryStackTrace. isCurrentStackTrace: False. Debug: Running main event processor on: Event d52b366ec9af4b9cb06e57c8833ef2d0 Debug: Envelope queued up. After SentrySdk.CaptureException Debug: Envelope 620db433f3474b7bb9b1b0e7782d434d successfully received by Sentry. Debug: Envelope d52b366ec9af4b9cb06e57c8833ef2d0 handed off to transport. #1 in queue. Debug: Envelope d52b366ec9af4b9cb06e57c8833ef2d0 successfully received by Sentry. Debug: Using ‘GzipBufferedRequestBodyHandler’ body compression strategy with level Optimal. Debug: Initializing Hub for Dsn: ‘https://1111@2222.ingest.sentry.io/3333’. Debug: Registering integration: ‘AutoSessionTrackingIntegration’. Debug: Registering integration: ‘AppDomainUnhandledExceptionIntegration’. Debug: Registering integration: ‘AppDomainProcessExitIntegration’. Debug: Registering integration: ‘TaskUnobservedTaskExceptionIntegration’. Debug: Registering integration: ‘NetFxInstallationsIntegration’. Debug: New scope pushed. Before SentrySdk.CaptureMessage Info: Capturing event. Debug: Running main event processor on: Event 84374b4dbca54381b7dc25f3c0b341eb Debug: No Exception and AttachStacktrace is off. No stack trace will be collected. Debug: Envelope queued up. After SentrySdk.CaptureMessage Debug: Envelope 84374b4dbca54381b7dc25f3c0b341eb handed off to transport. #1 in queue. Before SentrySdk.CaptureException Exception thrown: ‘System.Exception’ in DB_GUI.exe Debug: Failed to report an error on a session because there is none active. Info: Capturing event. Debug: Running processor on exception: Testing. Debug: Creating SentryStackTrace. isCurrentStackTrace: False. Debug: Running main event processor on: Event 9f02d0fcb380423e825705da8bc1f436 Debug: Envelope queued up. After SentrySdk.CaptureException Debug: Envelope 84374b4dbca54381b7dc25f3c0b341eb successfully received by Sentry. Debug: Envelope 9f02d0fcb380423e825705da8bc1f436 handed off to transport. #1 in queue. Debug: Envelope 9f02d0fcb380423e825705da8bc1f436 successfully received by Sentry. Info: Disposing the Hub. Debug: Disposing SentryClient. Debug: Disposing BackgroundWorker. Debug: Shutdown scheduled. Stopping by: 00:00:02. #0 in queue. Info: Exiting the worker with an empty queue. Debug: Disposing scope. Debug: Disposing SentryScopeManager.

0reactions
nhinzevtcommented, Jul 14, 2021

I changed the initialization code to the following using SDK 3.8:

        Dim options As New SentryOptions
        options.Dsn = "https://1111@2222.ingest.sentry.io/33333"
        options.Debug = True
        options.DiagnosticLogger = New ConsoleDiagnosticLogger(SentryLevel.Debug)
        SentrySdk.Init(options)

The log seems more promising, but I have yet to find a way to resolve the dependency issue.

  Debug: Using 'GzipBufferedRequestBodyHandler' body compression strategy with level Optimal.
  Debug: Initializing Hub for Dsn: 'https://1111@2222.ingest.sentry.io/3333'.
  Debug: Registering integration: 'AutoSessionTrackingIntegration'.
  Debug: Registering integration: 'AppDomainUnhandledExceptionIntegration'.
  Debug: Registering integration: 'AppDomainProcessExitIntegration'.
  Debug: Registering integration: 'TaskUnobservedTaskExceptionIntegration'.
  Debug: Registering integration: 'NetFxInstallationsIntegration'.
  Debug: New scope pushed.
Before SentrySdk.CaptureMessage
   Info: Capturing event.
  Debug: Running main event processor on: Event e8338e1b7b1d4aa895bc9b74efec543e
  Debug: No Exception and AttachStacktrace is off. No stack trace will be collected.
  Debug: Envelope queued up.
After SentrySdk.CaptureMessage
  Debug: Envelope e8338e1b7b1d4aa895bc9b74efec543e handed off to transport. #1 in queue.
  Error: Error while processing envelope (event ID: 'e8338e1b7b1d4aa895bc9b74efec543e'). #1 in queue.
System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   --- End of inner exception stack trace ---
   at Sentry.Internal.PooledBuffer`1..ctor(Int32 minimumLength)
   at Sentry.Internal.Extensions.StreamExtensions.<WriteByteAsync>d__2.MoveNext() in /_/src/Sentry/Internal/Extensions/StreamExtensions.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Protocol.Envelopes.Envelope.<SerializeAsync>d__10.MoveNext() in /_/src/Sentry/Envelopes/Envelope.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.EnvelopeHttpContent.<SerializeToStreamAsync>d__2.MoveNext() in /_/src/Sentry/Internal/Http/EnvelopeHttpContent.cs:line 16
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.GzipBufferedRequestBodyHandler.<SendAsync>d__3.MoveNext() in /_/src/Sentry/Internal/Http/GzipBufferedRequestBodyHandler.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.RetryAfterHandler.<SendAsync>d__7.MoveNext() in /_/src/Sentry/Internal/Http/RetryAfterHandler.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.HttpTransport.<SendEnvelopeAsync>d__13.MoveNext() in /_/src/Sentry/Internal/Http/HttpTransport.cs:line 161
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
Before SentrySdk.CaptureException
Exception thrown: 'System.Exception' in DB_GUI.exe
   at Sentry.Internal.BackgroundWorker.<WorkerAsync>d__19.MoveNext() in /_/src/Sentry/Internal/BackgroundWorker.cs:line 134  Debug: Failed to report an error on a session because there is none active.
   Info: Capturing event.
  Debug: Running processor on exception: Testing.
  Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
  Debug: Running main event processor on: Event 1430b4c978df4191892450e1d82a655e
  Debug: Envelope queued up.
After SentrySdk.CaptureException
  Debug: Envelope 1430b4c978df4191892450e1d82a655e handed off to transport. #1 in queue.
  Error: Error while processing envelope (event ID: '1430b4c978df4191892450e1d82a655e'). #1 in queue.
System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   --- End of inner exception stack trace ---
   at Sentry.Internal.PooledBuffer`1..ctor(Int32 minimumLength)
   at Sentry.Internal.Extensions.StreamExtensions.<WriteByteAsync>d__2.MoveNext() in /_/src/Sentry/Internal/Extensions/StreamExtensions.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Protocol.Envelopes.Envelope.<SerializeAsync>d__10.MoveNext() in /_/src/Sentry/Envelopes/Envelope.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.EnvelopeHttpContent.<SerializeToStreamAsync>d__2.MoveNext() in /_/src/Sentry/Internal/Http/EnvelopeHttpContent.cs:line 16
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.GzipBufferedRequestBodyHandler.<SendAsync>d__3.MoveNext() in /_/src/Sentry/Internal/Http/GzipBufferedRequestBodyHandler.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.RetryAfterHandler.<SendAsync>d__7.MoveNext() in /_/src/Sentry/Internal/Http/RetryAfterHandler.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Sentry.Internal.Http.HttpTransport.<SendEnvelopeAsync>d__13.MoveNext() in /_/src/Sentry/Internal/Http/HttpTransport.cs:line 161
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting for .NET
Learn more about how to troubleshoot common issues with the .NET SDK.
Read more >
SentrySDK VB.NET initialization example
How do I convert the SentrySDK C# initialization code to VB.NET? using (SentrySdk.Init(o => { o.Dsn = "https://examplePublicKey@o0.ingest.sentry ...
Read more >
Duplicate invocations of Sentry SDK initialization conflict ...
NET 5 and Sentry SDK version 3.0.6 ... The following code DOES NOT work: ... EF Core uses ILogger like any other part...
Read more >
sentry-dotnet
Sentry SDK for .NET. Readme; Issues. Sentry. Bad software is everywhere, and we're tired of it. Sentry is on a mission to help...
Read more >
Sentry 3.35.1
Official SDK for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.
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