Using ApplicationService layer from another project ABP - aspnetboilerplate

I have added another project to my ABP and I need to access to ApplicationService methods, I've created a module for my new project here is the code
[DependsOn(
typeof(PrestamosApplicationModule),
typeof(PrestamosEntityFrameworkCoreModule))]
public class ReportsApplicationModule : AbpModule
{
public ReportsApplicationModule(PrestamosEntityFrameworkCoreModule abpZeroTemplateEntityFrameworkCoreModule)
{
abpZeroTemplateEntityFrameworkCoreModule.SkipDbContextRegistration = true;
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(ReportsApplicationModule).GetAssembly());
//ServiceCollectionRegistrar.Register(IocManager);
}
public override void PreInitialize()
{
base.PreInitialize();
}
}
The Program.cs class
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureServices((hostContext, services) =>
{
var abpBootstrapper = AbpBootstrapper.Create<ReportsApplicationModule>();
services.AddSingleton(abpBootstrapper);
WindsorRegistrationHelper.CreateServiceProvider(abpBootstrapper.IocManager.IocContainer, services);
});
}
My problem is when I want to use an AppService
public ReporteClienteController(IClienteAppService clienteAppService)
{
_clienteAppService = clienteAppService;
}
I got the following error
InvalidOperationException: Unable to resolve service for type 'DomiSys.Prestamos.Generales.ClienteNs.IClienteAppService' while attempting to activate 'DomiSys.Prestamos.Reports.Controllers.ReporteClienteController'.
Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, bool isDefaultParameterRequired)
lambda_method(Closure , IServiceProvider , object[] )
Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider+<>c__DisplayClass4_0.b__0(ControllerContext controllerContext)
Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider+<>c__DisplayClass5_0.g__CreateController|0(ControllerContext controllerContext)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
What is wrong?, how can I configure the module correctly to use the depence Injection ?

Can you try replacing PrestamosApplicationModule with PrestamosCoreModule.
And I guess that part of code is not necessary
.ConfigureServices((hostContext, services) =>
{
var abpBootstrapper = AbpBootstrapper.Create<ReportsApplicationModule>();
services.AddSingleton(abpBootstrapper);
WindsorRegistrationHelper.CreateServiceProvider(abpBootstrapper.IocManager.IocContainer, services);
});

Related

Test MassTransit state machine saga activity

I'm trying to do unit tests on a custom Activity that I have for my MassTransit state machine saga.
It looks something like this:
public class UpdateActivity : Activity<UpdateState>
{
private readonly ConsumeContext _consumeContext;
private readonly ILogger<UpdateActivity> _logger;
public UpdateActivity(
ConsumeContext consumeContext,
ILogger<UpdateActivity> logger
)
{
_consumeContext = consumeContext;
_logger = logger;
}
public void Probe(ProbeContext context) => context.CreateScope(nameof(UpdateActivity));
public void Accept(StateMachineVisitor visitor) => visitor.Visit(this);
public async Task Execute(BehaviorContext<UpdateState> context, Behavior<UpdateState> next)
{
await DoStuffAsync(context.Instance);
await next.Execute(context).ConfigureAwait(false);
}
public async Task Execute<T>(BehaviorContext<UpdateState, T> context, Behavior<UpdateState, T> next)
{
await DoStuffAsync(context.Instance);
await next.Execute(context).ConfigureAwait(false);
}
public Task Faulted<TException>(BehaviorExceptionContext<UpdateState, TException> context, Behavior<UpdateState> next) where TException : Exception
=> next.Faulted(context);
public Task Faulted<T, TException>(BehaviorExceptionContext<UpdateState, T, TException> context, Behavior<UpdateState, T> next) where TException : Exception
=> next.Faulted(context);
}
What I can't figure out is how I can mock/fake expectations for the ConsumeContext when writing unit tests for this class. I've tried to find something using the InMemoryTestHarness but can't find anything suitable.
EDIT:
I might as well throw this one as well in there. How do I mock context or run this in a test harness? So that I can unit test this Activity as well?
public class UpdateActivity : Activity<UpdateState, IDataUpdatedEvent>
{
private readonly ILogger<UpdateActivity> _logger;
public UpdateActivity(
ILogger<UpdateActivity > logger
)
{
_logger = logger;
}
public void Probe(ProbeContext context) => context.CreateScope(nameof(UpdateActivity));
public void Accept(StateMachineVisitor visitor) => visitor.Visit(this);
public async Task Execute(BehaviorContext<UpdateState, IDataUpdatedEvent> context, Behavior<UpdateState, IDataUpdatedEvent> next)
{
MassTransit has test harnesses to allow state machines to be tested, along with activities using Dependency Injection.
The idea of "testing in isolation with mocks" is fairly pointless given the availability of these harnesses.

Simple Injector inject dependency into custom global authentication filters and OWIN middle ware OAuthAuthorizationServerProvider

I used Simple Injector as our Ioc container; we have two problems.
We want to inject into our custom authentication filter; we read the post of converting attribute to a passive attribute: Convert Attribute into a passive. But we can't convert custom authentication filter attribute into a passive.
public class BearerAuthentication : Attribute, IAuthenticationFilter
{
public async Task AuthenticateAsync(
HttpAuthenticationContext context, CancellationToken cancellationToken)
{
}
public Task ChallengeAsync(
HttpAuthenticationChallengeContext context, CancellationToken cancellationToken)
{
}
}
We want to inject dependency into OWin middleware OAuthAuthorizationServerProvider; we know we can use begin execution context scope, but we want an elegant solution.
using (Ioc.Container.BeginExecutionContextScope())
{
}
Updated
public interface IAuthenticationFilter<TAttribute> where TAttribute : Attribute
{
Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken);
Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken);
}
public class BearerAuthenticationFilter : Attribute, IAuthenticationFilter<BearerAuthenticationFilter>
{
private readonly IAuthenticationBusinessEngine _authenticationBusinessEngine;
private readonly IHttpContextAccessor _httpContextAccessor;
public BearerAuthenticationFilter(IAuthenticationBusinessEngine authenticationBusinessEngine, IHttpContextAccessor httpContextAccessor)
{
_authenticationBusinessEngine = authenticationBusinessEngine;
_httpContextAccessor = httpContextAccessor;
}
public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
public class AuthenticationFilterDispatcher : IAuthenticationFilter
{
private readonly Func<Type, IEnumerable> _container;
public AuthenticationFilterDispatcher(Func<Type, IEnumerable> container)
{
_container = container;
}
public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
{
var descriptor = context.ActionContext.ActionDescriptor;
var attributes = descriptor.ControllerDescriptor.GetCustomAttributes<Attribute>(true)
.Concat(descriptor.GetCustomAttributes<Attribute>(true));
foreach (var attribute in attributes)
{
var filterType = typeof(IAuthenticationFilter<>).MakeGenericType(attribute.GetType());
var filters = _container.Invoke(filterType);
foreach (dynamic actionFilter in filters)
{
await actionFilter.AuthenticateAsync(context, cancellationToken);
}
}
}
public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public bool AllowMultiple
{
get
{
return true;
}
}
}
The equivalent code for working with IAuthenticationFilter is:
public interface IAuthenticationFilter<TAttribute> where TAttribute : Attribute
{
Task AuthenticateAsync(TAttribute attribute, HttpAuthenticationContext context);
}
public class AuthenticationFilterDispatcher : IAuthenticationFilter
{
private readonly Func<Type, IEnumerable> container;
public AuthenticationFilterDispatcher(Func<Type, IEnumerable> container) {
this.container = container;
}
public async Task AuthenticateAsync(HttpAuthenticationContext context,
CancellationToken token) {
var descriptor = context.ActionContext.ActionDescriptor;
var attributes = descriptor.ControllerDescriptor
.GetCustomAttributes<Attribute>(true)
.Concat(descriptor.GetCustomAttributes<Attribute>(true));
foreach (var attribute in attributes) {
Type filterType = typeof(IAuthenticationFilter<>)
.MakeGenericType(attribute.GetType());
IEnumerable filters = this.container.Invoke(filterType);
foreach (dynamic actionFilter in filters) {
await actionFilter.AuthenticateAsync((dynamic)attribute, context);
}
}
}
public async Task ChallengeAsync(HttpAuthenticationChallengeContext context,
CancellationToken token) { }
public bool AllowMultiple { get { return true; } }
}
Registration is done as follows:
GlobalConfiguration.Configuration.Filters.Add(
new AuthenticationFilterDispatcher(container.GetAllInstances));
// For Simple Injector 2.x:
container.RegisterManyForOpenGeneric(typeof(IAuthenticationFilter<>),
container.RegisterAll,
new[] { typeof(IAuthenticationFilter<>).Assembly });
// For Simple Injector 3.x:
container.RegisterCollection(typeof(IAuthenticationFilter<>),
new[] { typeof(IAuthenticationFilter<>).Assembly });
Now instead of making your attributes active, you can make the attribute passive and implement the required logic inside an IAuthenticationFilter<MyPassiveAttribute> implementation.
Your attribute and new component might look like this:
// NOTE: This attribute does not derive from anything Web API specific,
// just from Attribute
public class RequiresBearerAuthenticationAttribute : Attribute
{
// put here properties if required
}
public class BearerAuthenticationFilter
: IAuthenticationFilter<RequiresBearerAuthenticationAttribute>
{
private readonly IAuthenticationBusinessEngine _authenticationBusinessEngine;
private readonly IHttpContextAccessor _httpContextAccessor;
public BearerAuthenticationFilter(
IAuthenticationBusinessEngine authenticationBusinessEngine,
IHttpContextAccessor httpContextAccessor)
{
_authenticationBusinessEngine = authenticationBusinessEngine;
_httpContextAccessor = httpContextAccessor;
}
public async Task AuthenticateAsync(RequiresBearerAuthenticationAttribute attribute,
HttpAuthenticationContext context)
{
// TODO: Behavior here
}
}

EF 6 - Ninject - The operation cannot be completed because the dbcontext has been disposed

I've seen a lot of questions with this error, so sorry for asking again, but no solutions have worked for me so far.
I'm working on a ASP.NET Web API project that's using the Ninject and Ninject.Web.Common references, where a DbContext is injected into the repositories. This error pops up the second time I send a request subsequently.
My stack trace :
at System.Data.Entity.Internal.InternalContext.CheckContextNotDisposed()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.LazyInternalContext.get_ObjectContext()
at System.Data.Entity.Internal.InternalContext.DetectChanges(Boolean force)
at System.Data.Entity.Internal.InternalContext.GetStateEntries(Func`2 predicate)
at System.Data.Entity.Internal.InternalContext.GetStateEntries()
at System.Data.Entity.Infrastructure.DbChangeTracker.Entries()
at Project.Data.UnitOfWork.Commit() in c:\Projects\Project\src\DotNet\Project.Data\UnitOfWork.cs:line 22
at Project.Api.Infrastructure.UnitOfWorkAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext) in c:\Projects\Project\src\DotNet\Project.Api\Infrastructure\UnitOfWorkAttribute.cs:line 25
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__1.MoveNext()
Ninject : RegisterServices
kernel.Bind<DataContextFactory>().ToSelf().InRequestScope().WithConstructorArgument("nameOrConnectionString", "Project");
kernel.Bind<DataContext>().ToMethod(context => kernel.Get<DataContextFactory>().GetContext()).InRequestScope();
kernel.Bind<IRepository<Device>>().To<Repository<Device>>();
kernel.Bind<IRepository<Person>>().To<Repository<Person>>();
kernel.Bind<UnitOfWork>().ToSelf().InRequestScope();
kernel.BindHttpFilter<UnitOfWorkAttribute>(FilterScope.Controller).WhenControllerType<DeviceController>();
kernel.BindHttpFilter<UnitOfWorkAttribute>(FilterScope.Controller).WhenControllerType<PersonController>();
My IRepositiry class
public interface IRepository<TAggregateRoot> where TAggregateRoot : class, IAggregateRoot
{
void Save(TAggregateRoot instance);
void Remove(TAggregateRoot instance);
TAggregateRoot One(Expression<Func<TAggregateRoot, bool>> predicate = null, params Expression<Func<TAggregateRoot, object>>[] includes);
IQueryable<TAggregateRoot> All(Expression<Func<TAggregateRoot, bool>> predicate = null, params Expression<Func<TAggregateRoot, object>>[] includes);
bool Exists(Expression<Func<TAggregateRoot, bool>> predicate = null);
int Count(Expression<Func<TAggregateRoot, bool>> predicate = null);
}
My person controller class
public class PersonController : ApiController
{
private readonly IRepository<Person> _personRepository;
public PersonController(IRepository<Person> personRepository)
{
_personRepository = personRepository;
}
...
}
My DbContext
private readonly IDictionary _configurations;
public DataContext(string nameOrConnectionString, IDictionary<MethodInfo, object> configurations)
: base(nameOrConnectionString)
{
_configurations = configurations;
}
public virtual void MarkAsModified<TEntity>(TEntity instance) where TEntity : class
{
Entry(instance).State = EntityState.Modified;
}
public virtual IDbSet<TEntity> CreateSet<TEntity>() where TEntity : class
{
return Set<TEntity>();
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
if (modelBuilder == null)
{
throw new ArgumentNullException("modelBuilder");
}
foreach (var config in _configurations)
{
config.Key.Invoke(modelBuilder.Configurations, new[] { config.Value });
}
base.OnModelCreating(modelBuilder);
}

MVC3, Unity Framework and Per Session Lifetime Manager Issue

In a simple word I try to create Lifetime manager for Unity framework by using Http Session in my MVC3 project. My sample implementation of lifetime manager is:
public class UnityPerSessionLifetimeManager : LifetimeManager
{
private string sessionKey;
private HttpContext ctx;
public UnityPerSessionLifetimeManager(string sessionKey)
{
this.sessionKey = sessionKey;
this.ctx = HttpContext.Current;
}
public override object GetValue()
{
return this.ctx.Session[this.sessionKey];
}
public override void RemoveValue()
{
this.ctx.Items.Remove(this.sessionKey);
}
public override void SetValue(object newValue)
{
this.ctx.Session[this.sessionKey] = newValue;
}
}
In my global.asax.cs I replaced default controller factory with my own UnityControllerFactory
public class UnityControllerFactory : DefaultControllerFactory
{
private IUnityContainer container;
public UnityControllerFactory(IUnityContainer container)
{
this.container = container;
this.RegisterServices();
}
protected override IController GetControllerInstance(RequestContext context, Type controllerType)
{
if (controllerType != null)
{
return this.container.Resolve(controllerType) as IController;
}
return null;
}
private void RegisterServices()
{
this.container.RegisterType<IMyType, MyImpl>(new UnityPerSessionLifetimeManager("SomeKey"));
}
}
}
I set breakpoints on each function of UnityPerSessionLifetimeManager class, I noticed that when controller factory tries to solve dependencies of my controller, the HttpContext.Session is actually null, so the code fails retrieve from session or save to session.
Any idea why session is null at this stage?
My mistake, I should change code of UnityPerSessionLifetimeManager class to be
public class UnityPerSessionLifetimeManager : LifetimeManager
{
private string sessionKey;
public UnityPerSessionLifetimeManager(string sessionKey)
{
this.sessionKey = sessionKey;
}
public override object GetValue()
{
return HttpContext.Current.Session[this.sessionKey];
}
public override void RemoveValue()
{
HttpContext.Current.Session.Remove(this.sessionKey);
}
public override void SetValue(object newValue)
{
HttpContext.Current.Session[this.sessionKey] = newValue;
}
}
because when the constructor was called to register type, session state is not ready yet and I already assigned http context of that time to a variable. But in later Get/Set functions session state is ready.

Getting SNAP AOP Framework working with Ninject MVC 3

I want to try out so SOA style logging using Snap in my MVC3 application. I'm using Ninject for IoC so have installed Ninject.MVC and Snap.Ninject via Nuget all had a look at the sample code in GitHub for Snap.Ninject. I also read Getting SNAP(AOP), NInject and ASP.Net MVC 3 working together
which seems to be doing exactly what I want.
I've updated my NinjctMVC3.cs accordingly but when I add the interceptor attribute to my method, I get an object ref error from Snap AspectUtility. Here is my NinjectMVC3.cs
public static class NinjectMVC3 {
private static readonly Bootstrapper bootstrapper = new Bootstrapper();
/// <summary>
/// Starts the application
/// </summary>
public static void Start() {
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
DynamicModuleUtility.RegisterModule(typeof(HttpApplicationInitializationModule));
bootstrapper.Initialize(CreateKernel);
}
/// <summary>
/// Stops the application.
/// </summary>
public static void Stop() {
bootstrapper.ShutDown();
}
/// <summary>
/// Creates the kernel that will manage your application.
/// </summary>
/// <returns>The created kernel.</returns>
private static IKernel CreateKernel() {
//var kernel = new StandardKernel();
NinjectAopConfiguration.NinjectAopConfigure();
var kernel = NinjectAopConfiguration._container.Kernel;
RegisterServices(kernel);
return kernel;
}
/// <summary>
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel) {
kernel.Bind<ILogger>().To<NLogger>()
.WithConstructorArgument("currentClassName", x => x.Request.ParentContext.Request.Service.FullName); ;
kernel.Bind<ISomeDataFactory>().To<SomeDataFactory>();
}
}
public static class NinjectAopConfiguration {
public readonly static NinjectAspectContainer _container;
static NinjectAopConfiguration() {
_container = new NinjectAspectContainer();
}
public static void NinjectAopConfigure() {
SnapConfiguration.For(_container).Configure(c => {
c.IncludeNamespace("TestAopLogging.Model.*");
c.Bind<MyMethodInterceptor>().To<MyInterceptorAttribute>();
});
}
}
public class MyMethodInterceptor : MethodInterceptor {
public override void InterceptMethod(Castle.DynamicProxy.IInvocation invocation, MethodBase method, System.Attribute attribute) {
var logger = new NLogger(method.DeclaringType.ToString());
logger.LogInfo("Hello AOP Logger. Your method (" + method.Name + ") has been intercepted");
invocation.Proceed();
}
public override void BeforeInvocation() {
var logger = new NLogger("How do I work out what class I'm in?");
base.BeforeInvocation();
}
public override void AfterInvocation() {
var logger = new NLogger("How do I work out what class I'm in?");
logger.LogInfo("Hello AOP Logger. After Invocation");
base.AfterInvocation();
}
}
public class MyInterceptorAttribute : MethodInterceptAttribute { }
And the controller
public class HomeController : Controller
{
private ILogger _logger;
private ISomeDataFactory _someDataFactory;
public HomeController(ILogger logger, ISomeDataFactory someDataFactory) {
_logger = logger;
_someDataFactory = someDataFactory;
}
public ActionResult Index()
{
_logger.LogInfo("I've hit the index action");
_someDataFactory.GetStuffAndLogTheOldWay();
_someDataFactory.GetStuffAndLogUsingAOP();
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
public ActionResult About()
{
return View();
}
}
and the factory class with the method with the intercept attribute
public interface ISomeDataFactory {
string GetStuffAndLogTheOldWay();
string GetStuffAndLogUsingAOP();
}
public class SomeDataFactory : ISomeDataFactory {
private ILogger _logger;
public SomeDataFactory(ILogger logger) {
_logger = logger;
}
public string GetStuffAndLogTheOldWay() {
_logger.LogInfo(MethodBase.GetCurrentMethod().Name + " was called");
return "I called GetStuffAndLogTheOldWay";
}
[MyInterceptor] // If I comment this out, then all is good
public string GetStuffAndLogUsingAOP() {
return "I called GetStuffAndLogUsingAOP";
}
}
and this results in the following exception
[NullReferenceException: Object reference not set to an instance of an object.]
Snap.AspectUtility.CreateProxy(Type interfaceType, Object instanceToWrap, IInterceptor[] interceptors) +29
Snap.AspectUtility.CreatePseudoProxy(IMasterProxy proxy, Type interfaceType, Object instanceToWrap) +184
Snap.Ninject.AspectProxyActivationStrategy.Activate(IContext context, InstanceReference reference) +376
Ninject.Activation.<>c__DisplayClass2.b__0(IActivationStrategy s) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Pipeline.cs:58
Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable1 series, Action1 action) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:23
Ninject.Activation.Pipeline.Activate(IContext context, InstanceReference reference) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Pipeline.cs:58
Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Context.cs:182
Ninject.KernelBase.b__7(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\KernelBase.cs:375
System.Linq.<>c__DisplayClass123.<CombineSelectors>b__11(TSource x) +32
System.Linq.WhereSelectEnumerableIterator2.MoveNext() +151
System.Linq.Enumerable.SingleOrDefault(IEnumerable1 source) +4178557
Ninject.Planning.Targets.Target1.GetValue(Type service, IContext parent) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Planning\Targets\Target.cs:179
Ninject.Planning.Targets.Target1.ResolveWithin(IContext parent) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Planning\Targets\Target.cs:147
Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:97
Ninject.Activation.Providers.<>c__DisplayClass2.<Create>b__1(ITarget target) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81
System.Linq.WhereSelectArrayIterator2.MoveNext() +85
System.Linq.Buffer1..ctor(IEnumerable1 source) +325
System.Linq.Enumerable.ToArray(IEnumerable1 source) +78
Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81
Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Context.cs:157
Ninject.KernelBase.<Resolve>b__7(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\KernelBase.cs:375
System.Linq.<>c__DisplayClass123.b__11(TSource x) +32
System.Linq.WhereSelectEnumerableIterator2.MoveNext() +151
System.Linq.Enumerable.SingleOrDefault(IEnumerable1 source) +4178557
Ninject.Web.Mvc.NinjectDependencyResolver.GetService(Type serviceType) in c:\Projects\Ninject\Maintenance2.2\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectDependencyResolver.cs:56
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +51
Thanks in advance. I want a working demo of it failing then let me know.
Thanks to Tyler Brinks for spotting my typo!
Update the namespace reference to
c.IncludeNamespace("TestAopLogging.Models.*");
and all is well.
Hope someone finds this useful.

Resources