试图在C# Asp.Net核心3.1Console应用程序中运行bugsnag。我们已经将Bugsnag.AspNet.Core版本2.2.1添加到应用程序中。我们在应用程序中添加了Microsoft.Extensions.DependancyInjection版本3.1.15。
我们制作了一个简单的控制台应用程序,将其简化为试图使用bugsnag的基本应用程序。这是我们的密码。
class Program
{
static void Main(string[] args)
{
IServiceCollection services = new ServiceCollection();
services.AddBugsnag(configuration =>
{
configuration.ApiKey = "";
configuration.ReleaseStage = "Development";
});
var serviceProvider = services.BuildServiceProvider();
serviceProvider.GetService<DurationService>().SetCallSummary();
}
}还有服务。
public interface IDurationService
{
void SetCallSummary();
}
public class DurationService : IDurationService
{
private readonly Bugsnag.IClient _bugsnag;
public DurationService(Bugsnag.IClient client)
{
_bugsnag = client;
}
public void SetCallSummary()
{
try
{
throw new NotImplementedException();
} catch (Exception ex)
{
_bugsnag.Notify(ex);
}
}
}它始终无法初始化,说明在访问服务时存在空对象引用。空引用是对注入的bugsnag对象的引用。
请帮帮我!
发布于 2021-12-23 17:11:58
Bugsnag的ASP.NET核心库支持AP.NET Core1.x和2.x,运行在.NET Core (1.0+)或完整的.Net框架(4.6+)上。看起来您使用的是3.1版本,目前还不支持该版本。
https://stackoverflow.com/questions/67693204
复制相似问题