Elmah给出NullReferenceException

时间:2016-07-01 21:14:16

标签: .net asp.net-web-api asp.net-web-api2 elmah

当我执行这行代码时

Elmah.ErrorSignal.FromCurrentContext().Raise(context.Exception);

我收到以下错误

enter image description here

使用以下堆栈跟踪...

       at Elmah.Error..ctor(Exception e, HttpContext context)
   at Elmah.ErrorMailModule.OnError(Exception e, HttpContext context)
   at Elmah.ErrorMailModule.OnErrorSignaled(Object sender, ErrorSignalEventArgs args)
   at Elmah.ErrorSignalEventHandler.Invoke(Object sender, ErrorSignalEventArgs args)
   at Elmah.ErrorSignal.Raise(Exception e, HttpContext context)
   at Elmah.ErrorSignal.Raise(Exception e)
   at Ideal.API.Filters.UnhandledExceptionFilter.OnException(HttpActionExecutedContext context) in C:\Repositories\edgemvc-ideal\Ideal.API\Filters\HandleErrorActionFilter.cs:line 10
   at System.Web.Http.Filters.ExceptionFilterAttribute.OnExceptionAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)

我已尝试过多个版本的电子邮件

<elmah>
    <errorMail 
      from="from" 
      to="to" 
      subject="subject" 
      async="true|false" 
      smtpPort="587|0" 
      smtpServer="smtpServer" 
      userName="userName" 
      password="password"
      useSsl="true|false"/>
  </elmah>

这是我从谷歌得到的:( enter image description here

1 个答案:

答案 0 :(得分:0)

这里什么是null?根据提供的信息,似乎在执行上述代码时没有httpcontext。