Unable to capture events with c#SDK and .Net Core 3.1 in console application

Ho,

I installed SDK 2.1 in my .Net Core 3.1 project.
I follow up the instructions in the get started page, but I don’t receive any event.
Moreover, in the code snippet to raise an Divide by zero exception, the code does not compile, because the c# compiler fails when building because detect that the 0 constant will raise and Divide by zero, so I think you need to update the documentation.

My code is tas follows:

static void Main(string[] args)
{
using (SentrySdk.Init(“https://…”))
{
try
{

				Console.WriteLine("VAmos allá.");
				int res = 3;
				res -= 3;
				Console.WriteLine(1 / res);
			}
			catch (Exception ex)
			{
				SentrySdk.CaptureException(ex);
			}
		}
		Console.WriteLine("Hello World!");
	}
}

I debug the code and the CaptureExcepcion is executed without errors. HOwever, in the issues page I don’t see any event.
The key is collected from project settings page.

What am I doing wrong?

Thanks in advance!

Best regards,

Juanjo.

One common pitfall when running the code with the debugger is that once you stop the debugger, it kills the process.

When you call SentrySdk.CaptureException(..) it doesn’t block the thread to open a connection to Sentry to submit the event. Instead it adds the event to an in memory queue and processes it asynchronously on a background thread.

This is the reason we return a IDisposable from SentrySdk.Init, so that in case the process is about to exit, we can block on Dispose while we finish flushing any pending events to Sentry.

If you’re running with the debugger, make sure hit F5 on VS to let the process run to the end, calling the Dispose.

Also, note that we have many samples here: https://github.com/getsentry/sentry-dotnet/tree/master/samples

Add your own DSN and run it (like dotnet run).