ninject

Loading unreferenced dll MVC Ninject

梦想的初衷 提交于 2019-12-11 21:19:35
问题 I have an MVC4 project in which I am using Ninject as the DI Framework. The problem I am having is trying to split my DI bindings from my implementation as i do not want my main web project to reference all of my other projects. I have tried to create a separate project called Bindings which contains ninject modules: public class WebModuleBindings : NinjectModule { public override void Load() { Bind<IStaticDataRepository>().To<StaticDataRepository>(); } } I then load this DLL dynamically in

Ninject: Injection of dependency IntPtr into parameter method of constructor

一笑奈何 提交于 2019-12-11 20:16:12
问题 I got help earlier with this question: Ninject: Error Activating Strings @nemensv solved that one but I immediatley got a new exception regarding IntPtr. (see activation path below). Been looking through the ctor here Only place IntPtr shows up is in this line: Result r = Platform.SQLiteApi.Open(databasePathAsBytes, out handle, (int)openFlags, IntPtr.Zero); How can I solve this using ninject? Complete exception: Activation path: 6) Injection of dependency IntPtr into parameter method of

Setting up a convention for automatic factories

半腔热情 提交于 2019-12-11 19:42:09
问题 By defining a IDataRepositoryFactory non-generic interface with a generic Create method: public interface IDataRepositoryFactory { T Create<T>(DataContext context) where T : IDataRepository; // new non-generic interface } I'm able to avoid having to write factory implementations: _kernel.Bind(t => t.FromAssemblyContaining(typeof(DataRepository<>)) .SelectAllInterfaces() .EndingWith("RepositoryFactory") .BindToFactory()); _kernel.Bind(t => t.FromAssemblyContaining(typeof(DataRepository<>))

Norm.MongoException: Connection timeout trying to get connection from connection pool

こ雲淡風輕ζ 提交于 2019-12-11 17:09:15
问题 I'm using Rob's mvc startesite http://mvcstarter.codeplex.com/ with ASP.Net MVC 2, Ninject2, NoRM (http://github.com/atheken/NoRM) and MongoDB. It works so fast and the developpement is even faster but I'm facing a big problem, I at some points, get connection timeout. I can't figure out what I'm doing wrong. I already asked a question here : I get this error that I don't understand why, using NoRM and Mongo in my MVC project and here http://groups.google.com/group/norm-mongodb/browse_thread

What ninject binding should I use?

你离开我真会死。 提交于 2019-12-11 15:12:48
问题 public AccountController(IUserStore<ApplicationUser> userStore) { //uncommenting the following line, uses the correct context, but //unit testing fails to work, as it is overwritten, so I need to use IoC //to inject //userStore = new UserStore<ApplicationUser>(new ApplicationDbContext()); UserManager = new UserManager<ApplicationUser>(userStore); What should my ninject binding look like? The only thing that I could get to even compile looks like the following, but that is not getting the

“Argument not specified for parameter” using Ninject in web forms

ε祈祈猫儿з 提交于 2019-12-11 15:05:26
问题 Just to re-iterate the title, this is web forms and not mvc. Also it's using vb.net. I have used nuget to add ninject.web to my project. I have configured NinjectWebCommon's "RegisterServices" method as follows: Private Shared Sub RegisterServices(kernel As IKernel) kernel.Bind(Of ilbdUOW)().[To](Of lbdUOW)() End Sub Everything compiles clean. When I run the simple web form (.aspx page, no master page), I get the following error: BC30455: Argument not specified for parameter '_uow' of 'Public

Ninject to inject ILog dependency

谁说我不能喝 提交于 2019-12-11 12:59:06
问题 I have gone through some other posts in this forum that are related to Ninject and Log4net, but none seemed to address the issue (or resolve it). Code looks like IKernel kernel = new StandardKernel(new NinjectSettings() { LoadExtensions = true }); kernel.Load(Assembly.GetExecutingAssembly()); Program pgm = new Program(kernel.Get<IFSLog>()); Exception is thrown in the last line above with message "Error activating ILog. No matching bindings are available... " IFSLog is an interface defined in

Custom ModelBinder Lifecycle and Dependency Injection [duplicate]

冷暖自知 提交于 2019-12-11 12:57:51
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Inject a dependency into a custom model binder and using InRequestScope using Ninject I'm trying to bind an NHibernate session to a custom model binder: Since a custom model binder appears to be a singleton, I think I need to be concerned with thread safety. This is my current IoC code: kernel.Bind<ISession>().ToProvider<SessionProvider>().InRequestScope() .OnActivation(x => ServiceModelBinder.Service = kernel

Simple Injector Property Injection

早过忘川 提交于 2019-12-11 11:57:41
问题 How do you perform property injection with Simple Injector. The with Ninject you do is as per bellow: [Inject] public IUnitOfWork UnitOfWork { get; set; } How can I do the equivalent to this with Simple Injector. I tried finding a solution online but had no luck. Why do I want to use Property Injection? I want to use property injection to set up unit of work in my base controller so that it will create a new unit of work OnActionExecuting and commit the changes OnResultExecuted . It also

Ninject Cascading Constructor Arguments

烈酒焚心 提交于 2019-12-11 11:10:49
问题 I have a type IRoleRepository which accepts a constructor argument "database" which accepts a type of IDbRepository which itself takes a constructor argument "ConnectionStringName". I have a dependency resolver which has a GetService method and while the following code works I was hoping there would be better way to do this at Bind time vs at Get time with Ninject 3.0. Note I may have multiple IDBRepository instances each with their own "ConnectionStringName". _repository = EngineContext