I have class, which I use to register as GlobalFilter to handle execpions. I register it on global.asax, there everything is all right.
When exception occurs in my action, I enter in OhException method and get NullReference exception, becouse LogManager property is null.
Why nInject doesn't inject it?
public class HandleErrorFilterAttribute : HandleErrorAttribute
{
[Inject]
public ILogManager LogManager { get; set; }
public override void OnException(ExceptionContext filterContext)
{
LogManager.LogError("Unhandled exception thrown", filterContext.Exception);
base.OnException(filterContext);
}
}
This code below service injection (I forgot write about it)
kernel.Bind<ILogManager>().To<LogManager>();
And there I create object
public void RegisterGlobalFilters()
{
var handleErrorAttribute = new HandleErrorFilterAttribute();
GlobalFilters.Filters.Add(handleErrorAttribute);
}