bugsnag / bugsnag-dotnet

.NET notifier for BugSnag. Error monitoring and error reporting for .NET.
https://docs.bugsnag.com/platforms/dotnet/
MIT License
60 stars 29 forks source link

.NET 7.0 ASP.net website silently failing #163

Closed andysinclair closed 1 year ago

andysinclair commented 1 year ago

Describe the bug

BugSnag does not appear to be compatible with an ASP.net .NET 7.0 website. The code below compiles and runs with no error, but there is no error reported in the BugSnag dashboard. I can use the same code in a .NET 7.0 console application and it works as expected.

Environment

Example code snippet

var bugsnag = new Bugsnag.Client(new Configuration(API_KEY)); var ex = new Exception("Test error"); bugsnag.Notify(ex);

gareththackeray commented 1 year ago

Hi Andy. I couldn't reproduce the issue. I received an exception with the plan Bugsnag package, as you described:

using Bugsnag; 

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

app.MapGet("/error", () => {
    new Bugsnag.Client(new Configuration("API-KEY")).Notify(new Exception());
    return "error sent";
});

app.Run();

and with our ASP.NET package Bugsnag.AspNet.Core (which would be our recommended approach):

using Bugsnag.AspNet.Core;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddBugsnag(configuration => {
     configuration.ApiKey = "API-KEY";
});

var app = builder.Build();

app.MapGet("/error", () => {throw new Exception();});

app.Run();

From where exactly are you calling Notify?

andysinclair commented 1 year ago

Hi Gareth. Thanks for the reply and assistance. I changed my project to use Bugsnag.AspNet.Core and it is now working. I was reluctant to do this earlier as it involved updating a dependency package Microsoft.Extensions.Options.ConfigurationExtensions but it all seems good now. Will now start using the product and see if/how it can meet our requirements. Thanks!

johnkiely1 commented 1 year ago

HI @andysinclair, glad to hears its working now. Going to close this out.