In the Configure callback you are putting together a configuration which is used on all bindings and when you write multiple WhenClassHas and In...Scope statements you are basically overriding your own settings so all your type bindings will use the last statement cfg.WhenClassHas<BindInRequestScopeAttribute>().InRequestScope();. To solve this you need to use...
asp.net-mvc-4,ninject,ninject-extensions
In Unity that would be the Microsoft.Practices.Unity.IUnityContainer interface. This is the main interface in Unity which collects the methods for registration (RegisterType, RegisterInstance), resolvig (Resolve) , configuration (AddExtension) etc. See also on MSDN ...
c#,dependency-injection,ninject,ninject-extensions
I think you can try to use The Ninject Context Preservation Extension which adds support for recording (and making available to Contextual Binding rules) the context pertaining to factories that call the Kernel to Resolve Requests. This enables you to add contextual conditions to your Bindings....
c#,asp.net-mvc,ninject,ninject.web.mvc,ninject-extensions
I've found a "Solution" that works so far it's not perfect because I am avoiding the AppFabric Store with an Localstore for the Object Reference. public static IBindingNamedWithOrOnSyntax<T> InSessionScope<T>(this IBindingInSyntax<T> parent) { return parent.InScope(SessionScopeCallback); } public static Dictionary<string, object> LocalSessionStore = new Dictionary<string, object>(); private const string _sessionKey = "Ninject...
c#,generics,ninject,ninject-extensions
BindDefaultInterface means that MyService : IMyService, IWhatever will be bound to IMyService. You should use BindSingleInterface, which worked instantly when I tried it in a Unit Test: [TestMethod] public void TestMethod2() { var kernel = new StandardKernel(); kernel.Bind(c => c.FromThisAssembly() .IncludingNonePublicTypes() .SelectAllClasses() .InheritedFrom(typeof(IQueryHandler<,>)) .BindSingleInterface()); kernel.TryGet<IQueryHandler<GetPagedPostsQuery,PagedResult<Post>>>() .Should() .NotBeNull(); } ...
c#,wcf,ninject,ninject-extensions
After a massive amount of refactoring, I have this working, but I dont know if it is 'correct.' To get it working I had to basically create a new IKernel inside of my webservice class and also have it inherit from NinjectModule and configure bindings in there as well. Why...
c#,entity-framework,ninject,ninject-extensions
I'm not fully proficient with Ninject, but according to this page https://github.com/ninject/Ninject.Extensions.Factory/wiki/Factory-interface it seems that the instance returned by the factory is retrieved from the IResolutionRoot. My take would be that you have to register your IMyContext concrete type with a singleton lifetime type. (But it seems that it's not...