I'm using StructureMap to have an instance of an interface and I wrap it into a proxy with Castle DynamicProxy:
var proxy = generator.CreateInterfaceProxyWithTarget<T>(
ObjectFactory.GetInstance<T>()
, new SwitchInterceptor(isGranted, foundUser));
In the interceptor of type IInterceptor
, I've got this code:
public override void Intercept(IInvocation invocation)
{
if (this.CanExecute)
{
invocation.Proceed();
}
}
When CanExecute is true
, it always work but sometimes when CanExecute is false
, I've got a weird NullReferenceException
with a realy small stacktrace:
at Castle.Proxies.IGrantedReadProxy.ExecuteSomething()
I'm really lost and I don't know where to look. Do you have any idea about what the problem is?