When the Applicaiton is executing the code in Application_Start
it is still being initialized, and it is not handling any HttpRequest.
So the problem with your code is that HttpContext
is null. In fact, the line ´ErrorSignal.FromContext(context);´ will throw an ArgumentNullException
.
However, you can still use Elmah when there is no HttpContext (and it will basically log the error message and stack trace) as explained in this question.
So your catch would be:
catch (Exception e)
{
ErrorLog.GetDefault(null).Log(new Error(e));
}
Hope it helps!