GithubHelp home page GithubHelp logo

bugsnag / bugsnag-dotnet Goto Github PK

View Code? Open in Web Editor NEW
59.0 37.0 29.0 3.04 MB

.NET notifier for BugSnag. Error monitoring and error reporting for .NET.

Home Page: https://docs.bugsnag.com/platforms/dotnet/

License: MIT License

C# 99.26% PowerShell 0.11% Ruby 0.49% Gherkin 0.15%
bugsnag crash exception-handling exception-reporting exception-handler error-monitoring error-reporting error-handling unhandled-exceptions debug

bugsnag-dotnet's Introduction

Bugsnag Notifier for .NET

build status Documentation

The Bugsnag Notifier for .NET gives you instant notification of exceptions thrown from your .NET apps. Any uncaught exceptions will trigger a notification to be sent to your Bugsnag project.

Bugsnag captures errors in real-time from your web, mobile and desktop applications, helping you to understand and resolve them as fast as possible. Create a free account to start capturing exceptions from your applications.

Contents

Getting Started

Installation

Using Nuget (Recommended)

  • Install the Bugsnag package from Nuget.

Manual library reference

  • Download the latest Bugsnag.dll and reference it in your project

Sending a Test Notification

var configuration = new Bugsnag.Configuration("{API_KEY}");
var client = new Bugsnag.Client(configuration);

client.Notify(new System.Exception("Error!"));

Usage

Catching and Reporting Exceptions

var configuration = new Bugsnag.Configuration("{API_KEY}");
var client = new Bugsnag.Client(configuration);

throw new System.Exception("Error!");

Sending Handled Exceptions

var configuration = new Bugsnag.Configuration("{API_KEY}");
var client = new Bugsnag.Client(configuration);

try
{
	throw new System.Exception("Error!");
}
catch (System.Exception ex)
{
	client.Notify(ex);
}

Callbacks

var configuration = new Bugsnag.Configuration("{API_KEY}");
var client = new Bugsnag.Client(configuration);
client.BeforeNotify((report) => {
	report.Event.User = new Bugsnag.Payload.User {
    Id = "1",
    Name = "Testy McTest",
    Email = "[email protected]" };
});

Disabling Bugsnag in Debug Mode

var configuration = new Bugsnag.Configuration("{API_KEY}")
{
	ReleaseStage = "development",
	NotifyReleaseStages = new[] { "production" },
};
var client = new Bugsnag.Client(configuration);

try
{
	throw new System.Exception("Error!");
}
catch (System.Exception ex)
{
	client.Notify(ex);
}

Demo Applications

Demo applications which use the Bugsnag .NET library

Support

Contributing

We'd love you to file issues and send pull requests. The contributing guidelines details the process of building and testing bugsnag-dotnet, as well as the pull request process. Feel free to comment on existing issues for clarification or starting points.

License

The Bugsnag .NET notifier is free software released under the MIT License. See LICENSE.txt for details.

bugsnag-dotnet's People

Contributors

bugsnagbot avatar cawllec avatar jviolas avatar kattrali avatar martin308 avatar sgtfrankieboy avatar shamsulamry avatar steve-nester-uk avatar tomlongridge avatar tremlab avatar twometresteve avatar xpaw avatar yousif-bugsnag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bugsnag-dotnet's Issues

.Notify shouldn't require being on the UI thread

Currently, WPFClient registers BeforeNotify handler which requires UI thread access just to get the window title for error.Context.

at Bugsnag.Clients.WPFClient.<.cctor>b__0(Event error) in c:\projects\bugsnag-dotnet\src\Bugsnag\Clients\WPFClient.cs:line 23

If .Notify() is called from non UI thread, reporting an exception will generate an exception (quite unfortunate).
Solution is to probably wrap it in try/catch. Also, suggest not even running this code if error.Context is already set by the client's BeforeNotify.

Double exceptions from child actions in ASP.NET MVC

Description

In #42 the call of base.OnException was removed. It causes double reporting exceptions from child actions:

  • First from child action itself
  • Second from parent action

Steps to reproduce

I created minimal MVC 5 project to demonstrate and reproduce the problem: tkirill/bugsnag-double-exception.

  1. Build the project.
  2. Go to "/".
  3. Yellow error page will be displayed.
  4. Open "C:\logs\double-exception.log".

In the log file will be two exceptions but should be only one -- the last.

=============

System.NotImplementedException: The method or operation is not implemented.
   at DoubleException.HomeController.Exception() in C:\Users\t_kirill\workplace\bugsnag\double-exception\reproduce\DoubleException\DoubleException\HomeController.cs:line 17
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

=============

System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.NotImplementedException: The method or operation is not implemented.
   at DoubleException.HomeController.Exception() in C:\Users\t_kirill\workplace\bugsnag\double-exception\reproduce\DoubleException\DoubleException\HomeController.cs:line 17
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter)
   at System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues)
   at ASP._Page_Views_Home_Index_cshtml.Execute() in c:\Users\t_kirill\workplace\bugsnag\double-exception\reproduce\doubleexception\doubleexception\Views\Home\Index.cshtml:line 13
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

Why

HandleErrorAttribute.OnException contains corresponding if. I think this if should be in BugsnagExceptionHandler too. I checked this here.

There are other helpful ifs in HandleErrorAttribute.OnException: one, two.

I believe the good solution will be to inherit BugsnagExceptionHandler from FilterAttribute, IExceptionFilter and copy HandleErrorAttribute.OnException without rendering error view.

Can't mutate event

It used to be possible in 1.x to change severity, addToTab and so on in BeforeNotify.

How is this done in 2.x?

BugSnag silently fails if SSL certificate is not trusted

Not really an issue with Bugsnag, but something we came across with on-premise hosting, and I wanted to document this for future reference. I expect this to be closed as not-an-issue, but I did submit a pull request to add logging to the Windows EventLog to track down why Bugsnag fails in general.

Stack trace

Bugsnag failed to send error report with exception: System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at Bugsnag.Notifier.SendJson(String json)

Threads support

I would guess we could have threads support, and I see comments for it. If we do we should probably disable by default (as its not always useful on Web platforms etc) and allow people to enable it when it is (on WindowsForms etc)

Overriding original exceptions in ASP.NET MVC

TL;DR

When HandleErrorAttribute isn't used in the project, Bugsnag overrides original exceptions by exception about not found error view.

Description

We found this exception in our logs:

System.InvalidOperationException: The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Purchase/Error.aspx
~/Views/Purchase/Error.ascx
~/Views/Shared/Error.aspx
~/Views/Shared/Error.ascx
~/Views/Purchase/Error.cshtml
~/Views/Purchase/Error.vbhtml
~/Views/Shared/Error.cshtml
~/Views/Shared/Error.vbhtml
   at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Our custom error pages are static HTML so we don't need HandleErrorAttribute and we don't add it to GlobalFilters.Filters. However, rendering error view is what HandleErrorAttribute does and it was strange that the errors appeared in our logs.

Surprisingly it was BugsnagExceptionHandler who tried to render error view. After we disabled it the error disappears and we could see original exceptions which cause BugsnagExceptionHandler to run.

Steps to reproduce

I created minimal MVC 5 project to demonstrate and reproduce the problem: tkirill/bugsnag-eat-exception-reproduce.

Steps to reproduce:

  1. Put API key in Web.config.
  2. Build project.
  3. Navigate to the root page "/".
  4. Custom 500 page will be displayed.
  5. Comment out Bugsnag action filter in Global.asax.cs.
  6. Rebuild project.
  7. Navigate to the root page "/".
  8. Custom 500 page will be displayed again.
  9. Open C:\logs\eat-exceptions.log.

In the log file will be two exceptions:

  • One about not found error view. This is the case then Bugsnag action filter activated.
  • One about original exception -- InvalidOperationException. This is the case then Bugsnag action filter disabled.

Additional possible problem

Likely the same problem occurs when someone use HandleErrorAttribute with custom view name set in the corresponding .View property.

Why

I believe the call of base.OnException causes the problem. Source code of HandleErrorAttribute proves this assumption.

What is expected

As for me the expected behavior of BugsnagExceptionHandler is only reporting exceptions to Bugsnag. Trying to display error page isn't its responsibility.

OWIN-based app in infinite `UnobservedTaskException` handler loop?

Hey guys,

I recently upgraded my Nancy .NET app to run on OWIN/Katana.

All was fine, then all of a sudden in production after some load i the app was locked (no requests were being served), and i saw an influx of BugSnag errors (like 100s of 1000s in a matter of seconds):
image

From my understanding, this basically means the client closed the connection (e.g closed browser, etc). It can happen. But this error was thrown and thrown a massive number of times and locked the app.

I repro'd locally by slamming my .NET app with a console app/stress tester, then closing the app, then starting the app again.

When i paused the debugger, i noted the app was stuck on this line:
capture3

When i say "stuck", i mean either it's blocking on that line, or the error is being rethrown so much that it's always on that line. Is it trying to install a handler each time for that exception, then re-throwing error, then installing handler again etc?

I'm using BugSnag in my OnError Nancy handler (basically, a global error handler) like so:

var bugSnag = new BaseClient("myApiKey");
bugSnag.Notify("something");

So anytime an error is thrown in my app, i do the above.

So nothing new there. BugSnag reporting was working fine for around a year, only when i upgraded to OWIN/Katana did this problem surface.

If i take out my BugSnag reporting code, my app doesn't crash.

Can anyone shed some light on this? Do i need to create a singleton BaseClient? Or does the current implementation of this library simply not support OWIN/Katana?

Im on BugSnag v1.2.0.0.

Thanks.

Setting releaseStage after injecting

Hi,

I am using Asp.Net Core. In order to get the releaseStage we need IHostingEnvironment env to be available. But it's not available in the ConfigureServices function. Trying to set it in other places gives an error - readonly property.

FileNotFoundException when using newer version of Newtonsoft.Json

In NuGet manager BugSnag claims to support Newtonsoft.Json (>= 6.0.1), but when I use the latest version (10.0.3) I get the following exception:

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

It works fine when using version 6.0.1. Is there any way to use the latest version of Newtonsoft.Json with BugSnag?

ASP.NET 5 support

ASP.NET 5 includes substantial changes that the BugSnag notifier will need to be modified to support, including:

  • all MVC-related types have moved to Microsoft.AspNet namespace; the exception handler filter will need to be modified to cater for these.
  • ConfigurationSettingsHandlers are no longer used (no web.config, ideally), so setup/config should be done via an IApplicationBuilder extension method.
  • it would be nice to also have an ILogger implementation and notify at certain log levels - not sure if this behaviour is in line with that provided on other platforms.

This will most likely need to be provided via a separate NuGet package; it may be a battle to try and support different MVC versions in the one assembly.

BugsnagMono always raise exception on MacOSX because it tries to load WPF assemblies.

Expected behavior

Mono application is able to load BugsnagMono assembly on MacOSX without any error.
https://www.nuget.org/packages/BugsnagMono/

Observed behavior

When Mono application loads BugSnagMono assembly on MacOSX, BugSnagMono assembly raises System.IO.FileNotFoundException, because it loads WPF assemblies. these assembly are not supported by mono framework.

http://www.mono-project.com/docs/gui/wpf/

I got below stacktraces when debug my application by Visual Studio for Mac.

...
Loaded assembly: /Solution/MyProject/bin/Debug/MyProject.app/Contents/MonoBundle/System.Net.Http.dll [External]
Loaded assembly: /Solution/MyProject/bin/Debug/MyProject.app/Contents/MonoBundle/System.Data.Linq.dll [External]
System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework' or one of its dependencies
File name: 'PresentationFramework'

...

Could not find `PresentationFramework` referenced by assembly `BugsnagMono, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null`.
Could not find `PresentationFramework` referenced by assembly `MyProject, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null`.
...

Steps to reproduce

  1. Create Xamarin.Mac project by Visual Studio for Mac.
  2. Add BugsnagMono package to the project.
  3. Build and Start debug it app.

Version

1.4.0.0

Additional information

BugsnagMono refers WPF assemblies, but these assemblies are provided for only Windows.
I try to use BugsnagMono from my Xamarin.Mac application on MacOSX.
However, the application cannot boot because BugsnagMono raises System.IO.FileNotFoundException. The mono framework does not support WPF framework.

http://www.mono-project.com/docs/gui/wpf/

Therefore, I believe BugsnagMono should not refer to WPF assemblies. Specifically, PresentationCore, PresentationFramework, and System.Deployment assemblies.

Full stacktraces is below.

...
Loaded assembly: /Solution/MyProject/bin/Debug/MyProject.app/Contents/MonoBundle/System.Net.Http.dll [External]
Loaded assembly: /Solution/MyProject/bin/Debug/MyProject.app/Contents/MonoBundle/System.Data.Linq.dll [External]
System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework' or one of its dependencies
File name: 'PresentationFramework'
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x0006f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/3.8.1.0/src/mono/mcs/class/corlib/System/AppDomain.cs:746 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/3.8.1.0/src/mono/mcs/class/corlib/System/AppDomain.cs:714 
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
  at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/3.8.1.0/src/mono/mcs/class/corlib/System.Reflection/Assembly.cs:600 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in /Users/builder/data/lanes/5143/124197ee/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:464 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in /Users/builder/data/lanes/5143/124197ee/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:464 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in /Users/builder/data/lanes/5143/124197ee/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:464 
  at ObjCRuntime.Runtime.RegisterEntryAssembly (System.Reflection.Assembly entry_assembly) [0x00035] in /Users/builder/data/lanes/5143/124197ee/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:425 
  at ObjCRuntime.Runtime.RegisterAssemblies () [0x00006] in /Users/builder/data/lanes/5143/124197ee/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:401 
  at AppKit.NSApplication.Init () [0x00022] in /Users/builder/data/lanes/5143/124197ee/source/xamarin-macios/src/AppKit/NSApplication.cs:60 
  at MyProject.MainClass.Main (System.String[] args) [0x00050] in /Solution/MyProject/Main.cs:26 
Finished
Could not find `PresentationFramework` referenced by assembly `BugsnagMono, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null`.
Could not find `PresentationFramework` referenced by assembly `MyProject, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null`.
...

Azure permissions

Unable to notify of an exception on azure ->

Exception=System.TypeInitializationException: The type initializer for 'Bugsnag.Diagnostics' threw an exception. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at System.Management.ManagementScope.InitializeGuts(Object o)
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObjectSearcher.Initialize()
at System.Management.ManagementObjectSearcher.Get()
at Bugsnag.Diagnostics.IsServerVersion()
at Bugsnag.Diagnostics.GetWin32NTVersion()
at Bugsnag.Diagnostics.GetOSInfo()
at Bugsnag.Diagnostics..cctor()

IgnoreClasses configuration does not support types from external assemblies

Specifying classes to be ignored from reporting does not always result in those classes being ignored. Classes contained under the System namespace appear okay, but others from external assemblies (such as ASP.NET MVC's HttpAntiForgeryException) never get ignored.

We have been trying to use the following:

<bugsnag apiKey="APIKEY"  ignoreClasses="System.Web.Mvc.HttpAntiForgeryException" />

The result of this should be that any HttpAntiForgery exceptions are ignored. However, the actual result is that these are being reported and appear in our dashboard.

From some initial tests, it appears this simplified reference to System.Web.Mvc.HttpAntiForgeryException is the problem, as the code in the Bugsnag.ConfigurationSection.Configuration.IgnoreClasses property getter isn't attempting to resolve types from all assemblies loaded in the current app domain.

I can suggest two possible fixes for this, however they come with their own pro's and con's.

OPTION 1: Alter IgnoreClasses to allow specifying the assembly name with the type name

Instead of System.Web.Mvc.HttpAntiForgeryException, by specifying the assembly name in the form of System.Web.Mvc.HttpAntiForgeryException,System.Web.Mvc allows the call to Type.GetType(string) to correctly resolve the type.

Here's a basic working sample (although this does not address cases of specifying a single fully qualified type name without a trailing semicolon and will cause the type and assembly name to be split in this case):

var resolveWithAssemblyNames = InternalIgnoreClasses.Contains(";");

_ignoreClasses = InternalIgnoreClasses
	.Split(resolveWithAssemblyNames ? ';' : ',')
	.Select(c => Type.GetType(c))
	.Where(t => t != null)
	.ToArray();

Pro's

  • Types will be resolved correctly
  • Very simple code change

Con's

  • This would change how this value is expected to be set in an apps webconfig.xml or app.xml file as the string could no longer be split on the comma. Instead, to support this, multiple types would have to be separated by a different character in order to allow adding the assembly name to the type name.

OPTION 2: Attempt to resolve the types from all assemblies loaded by the current app domain

To correctly find types without knowing the assembly name, the only reliable way I have found is to scan through all assemblies that are currently loaded.

This can be achieved with the following:

var matchClasses = InternalIgnoreClasses
		.Split(',');
		
_ignoreClasses = AppDomain.CurrentDomain.GetAssemblies()
		.Where(assembly => !assembly.IsDynamic)
		.SelectMany(assembly => assembly.GetTypes())
		.Where(type => matchClasses.Contains(type.FullName))
		.ToArray();

Pro's

  • This will find the type regardless of what assembly it is contained in (as long as the application references that assembly

Con's

  • All assemblies need to be scanned
  • Depending on how many assemblies are referenced, and how many types those assemblies contain, this method can cause significant delay. In a simple test with ASP.NET MVC and 5 other random NuGet packages added to a test project, resolving System.Web.Mvc.HttpAntiForgeryException added around 1 second in a very basic benchmark (debug mode was on, so not an entirely accurate comparison as you'd see in release mode).

Summary

I'm normally against changing/breaking something public and potentially widely used such as the expected format for ignoreClasses in the configuration file; but in this case, I believe it is the better of the two choices given the performance impact of scanning all assemblies.

Thoughts?

bugsnag not tracing unhandled exception for VSTO application.

Expected behavior

[Unhandled exception should be traced by bugsnag & shown to dashboard ]

Observed behavior

[Not making any track for Unhandled exception raised by VSTO application ]

Steps to reproduce

[Create test application which is build using VSTO template under visual studio & throw some error.]

Version

package id="Bugsnag" version="1.0.0.0" targetFramework="net45"

.NET 3.5 support

Install-Package : Could not install package 'Bugsnag 1.0.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

At line:1 char:1

  • Install-Package Bugsnag
  • CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
  • FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

In WebMVC set context

Can we put a better context in the WebMVC section. At the moment PATH_INFO looks good - but I need to double check that in the docs to make sure it doesnt have anything too dynamic in there

Create a Serilog sink

In my previous issue #37 I mention how NLog is like the de facto logging framework these days in .NET.

Well, Serilog is the new kid on the block and looks to be starting to get some traction.

So - a Serilog sink would be really awesome too ... and it's not hard to make.

It also looks like there's a large number of existing sinks already ... and some of those are competitor sinks. So if I was starting out a new project (and using Serilog) the first thing I'd check out is what sinks are available .. and I see your competitor's there .. so I guess that means a lot of people would be heading over there, instead of heading down to BugSnag (ie. discoverability).

or vice versa -> lets use bugsnag .. oh wait .. no serilog sink .. but there's logentries ... ok, LE it is....

.NET Core?

Are there any plans to support .NET Core?

Inner exceptions with no stack trace are dropped

When an error has an inner exception which does not include a stack trace and one cannot be generated, the inner exception is not included in the report to Bugsnag as it will be rejected by Bugsnag as invalid.

In this case a stack trace should be generated in some way as other information in the inner exception may be useful (for example the error message).

One approach would be to use the same stack trace as the outer exception.

Inner and aggregate exceptions

When our web apps get an AggregateException, the serialization of that exception into Bugsnag loses the details of the actual exceptions that are wrapped by the exception. I can see an Aggregate Exception occurred, but see no details of the exceptions themselves.

Along the same lines, when an Exception reported to Bugsnag has an inner exception, the details of the inner exception seem to be lost as well. There are cases where low-level exceptions are wrapped into more generalized exceptions by a library to customize error messaging and reporting.

Being unable to sort the inner exceptions of AggregateException and the inner exception (especially if a the inner exception also has an inner exception (recursively)), we are struggling to troubleshoot some of our production systems because details are natively lost from raised exceptions (the entire point of using a package like this). We can get around this by manually adding details into the custom tabs, but this is tedious and difficult to sell to other developers that we need to write so much custom code to make bugsnag work for us.

Notifier.Send can't leak exceptions

Notifier.Send must be enclosed in a try/catch to never ever leak an exception (except maybe if the debugger is attached?) Basically, right now, if there is no network it will bring down the process.

Say, I have an event I want to notify (that's non fatal) I call Client.Notify() bug I have no network - crash.

Validate API key

Currently we only check if supplied API key is not null or empty. Is there a better way to validate the key?

Memory leak eventually causing program to crash due to OutOfMemoryException

Tested few around of using and not using bugsnag (v2.0.2). Using bugsnag is causing OutOfMemoryException in a console application running on .Net 4.7.2 with high frequency of reported unhandled exception.

From the performance counter that I collected, the Gen 2 and large object heap size are steadily increasing.

User id in WindowsForms/Console

At the moment we use the windows login name - which will get a lot of duplicates around the world. Can we get some kind of user guid from windows? Like device id in ios

Windows 10 or Windows 8.1 is only detected correctly if added to app manifest

We currently use GetVersion to determine Windows version...

In Windows 8.1 and Windows 10, the GetVersion and GetVersionEx APIs have been deprecated and superseded by the Version Helper APIs. While you can still call the deprecated APIs, if your application does not specifically target Windows 8.1 or Windows 10, you will get Windows 8 version (6.2.0.0).

This causes Windows 8.1 and Windows 10 to be identified as Windows 8 by the Bugsnag notifier, if the OS is not added to the app manifest as a supported OS.

For more Info see here
https://msdn.microsoft.com/en-gb/library/windows/desktop/dn481241(v=vs.85).aspx#base.version_helper_apis
https://msdn.microsoft.com/en-gb/library/windows/desktop/ms724832(v=vs.85).aspx

Removing auto-generated 'Device' tab

I'm trying to get rid of the 'Device' tab in the metadata.

I'm trying this, with no luck :

bugsnag.Config.BeforeNotify(error =>
{
  error.Metadata.RemoveTab("DEVICE");
  return true;
});

How can I get rid of this tab ?

2.0 Upgrade Issues (Error => Report loses ability to set User information)

error below used to be Error type, but is now Report type.

We used to be able to set User values like this using BeforeNotify:

XXX.Client.BeforeNotify(error =>
{
    error.UserEmail = identity.Identity.GetUserId();
    error.UserId = email;
    error.UserName = identity.Identity.Name;
}

Now that error is Report, we do not have that ability.

This was not mentioned in the upgrade docs.

Create an NLog target

Hi Team.

NLog is one of the most widely used logging frameworks in .NET today, superseding Log4Net.

Could we please have an NLog target so we can have another option for logging to Bugsnag?

References: LogEntries Targets documentation.

Pro Tip: There's plenty of existing targets already coded for .NET, but for other companies. It's not hard to use those as references to get a target up and running really quick ๐Ÿ‘

Deal with offline crashes

We should cache them somewhere and send them later.

This is required for windows forms apps, windows phone and xamarin etc.

Automatically detect stacktrace prefixes

There is a common problem where an app is being built on multiple developers machines, and the stacktrace file names differ due to this, eg:

  • c:\users\james\myapp.cs
  • c:\users\simon\myapp.cs

Is there a way to automatically detect the stacktrace prefix for an app? If so that would be awesome.

Alternatively it would be great if we could allow regular expressions in SetFilePrefix.

StackTrace line are never detected as in project

I'm testing Bugsnag with version 2.0.2 and it seems that when settings multiple project namespaces, method of stacktrace are not detected as in the project.
I've looked in the Bugsnag code and it's because of the loop on each namespace in the internal middleware DetectInProjectNamespaces. With the way InProject property is updated, it will be true only if the last namespace is the one of the method.

sign Bugsnag.dll

Expected behavior

NuGet installed packages to provide signed assemblies.

Observed behavior

app crash when adding NuGet package to a signed app

System.IO.FileLoadException: 'Could not load file or assembly 'Bugsnag, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)'

Steps to reproduce

  1. Create signed .NET app (WPF, console, WinForms - doesn't matter)
  2. add nuget package Bugsnag
  3. build and run

Version

1.4.0.0

Support app type

Support setting of app type which is an indexed field in the dashboard.

Windows Forms Context

Windows forms context would be good. Perhaps we could somehow get the view that was on screen/on top in that case?

2.0 Upgrade Issue (Metadata.AddToTab Missing)

We used to be able to do this inside XXX.Client.BeforeNotify delegate:

var tabName = "My Fancy Tab";
error.Metadata.AddToTab(tabName, "EndpointUrl", $"https://{ConfigurationManager.AppSettings["applicationHostName"]}");
error.Metadata.AddToTab(tabName, "LicenseExpireDate", RPlusContext.GetLicenseExpiration().Value.ToString("o"));
error.Metadata.AddToTab(tabName, "LicenseFeatures", engine.GetLicenseFeatures());
error.Metadata.AddToTab(tabName, "LicenseStatus", engine.GetLicenseStatus(ConfigurationManager.AppSettings["applicationHostName"]).ToString());
error.Metadata.AddToTab(tabName, "LocalTimeZoneName", SettingsManager.Execute(UnityConfig.Resolve<IRepositoryFactory>(), obj => obj.GetTimeZoneSettings())?.TimeZoneName);
error.Metadata.AddToTab(tabName, "DataCenter", ConfigurationManager.AppSettings["DC"]);

But that method has vanished completely.

This was not mentioned in the upgrade docs.

[.NET Core] All Errors are showing URL https://****.com/Home/Error

Expected behavior

Show the original URL where the error occured

Observed behavior

Shows the error URL

Version

2.0.12-alpha

Here is the Bugsnag Setup
services.AddBugsnag(config => { config.ApiKey = _options.BugSnag.ApiKey; config.NotifyReleaseStages = new[] { "production" }; });

And here is the code that sets the error URL
app.UseExceptionHandler("/Home/Error");

2.0 Upgrade Issue (Unable to access WebAPI client outside of request lifecycle)

Related to #93 ...

We used to configure all our clients programtically in Global.asax.cs, but ran into issue with the 2.0 upgrade.

We used to be able to set config values, and delegates on the global client instance like so:

WebMVCClient.Config.XXX = xxx;
WebAPIClient.Config.XXX = xxx;

Now we have:

// NOTE: All config values are read-only now
Bugsnag.AspNet.Client.Current.XXX = xxx;

// Request is null ...
Request.Bugsnag().XXX = xxx;

Was not mentioned in the update docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.