ninject

No parameterless constructor error in WebJobs with .NET Core and Ninject

大兔子大兔子 提交于 2019-12-20 07:51:30
问题 I'm trying to do a bit of a balancing act here. Currently Azure WebJobs don't support .NET Core. With some help, I created a .NET Core Console App and made it work as a WebJob. On top of that I'm trying to implement Ninject for DI. Code compiles fine but when I run it, I'm getting the "No parameterless constructor is defined for this object." error -- see below. I may be in a bit of unchartered territory here with Azure WebJobs, .NET Core 2.0 and Ninject but any idea what may be causing this?

Can't get value of Ninject ConstructorArgument (passed in as parameter to kernel.Get)

旧巷老猫 提交于 2019-12-20 07:19:40
问题 Having trouble getting the value of a ConstructorArgument parameter passed to kernel.Get(). I want to use the parameter's value to determine which of two string values will be passed into the constructor. The parameter is in fact there when expected, I just can't get at its value. I end up with a null ref exception after calling the parameter's GetValue method: namespace MyNS.DBProviders { public abstract class DBProviderBase { private ObjectContext _db; public DBProviderBase(ObjectContext db

Ninject, DbContext & Windows Service - New Instance Each Time Thread Runs?

空扰寡人 提交于 2019-12-20 06:16:52
问题 I'm current writing a Windows Service which connects to an existing service layer using Entity Framework (DbContext), and Ninject to inject the Respositories and DbContext instance. This is pretty much working with one caveat - I want a brand new DbContext instance each time the thread runs, whereas at the moment I'm getting the same one for the entire thread lifetime. My binding looks like this: Bind<IDbContext>().To<EnterpriseDbContext>().InThreadScope(); Bind<IUserRepository>().To

What is self-binding in an IoC container?

一世执手 提交于 2019-12-20 03:31:22
问题 I've seen frameworks like Ninject as well as posts on Stack speak about self binding when using dependency injection frameworks like in the code below. Bind<Samurai>().To<Samurai>(); They even go to the extent of having special syntax for this: Bind<Samurai>().ToSelf(); Why would you want to bind a type to itself? I don't see any practical applications for where this might be useful and help reduce dependencies in code. Wouldn't this just mean a reference to a type would simply resolve to

Ninject with MVC3 RTM

╄→尐↘猪︶ㄣ 提交于 2019-12-20 03:11:51
问题 I've upgraded MVC3 from RC2 to RTM. We were using Ninject 2.1.0.76, but things stopped working once I upgraded. So I used the NuGet manager to get the latest Ninject, Ninject.MVC3 and Ninject.Web.Mvc libraries (2.1.0.91, 1.0.0.0 and 2.1.0.39 respectively). Now, it creates an AppStart_NinjectMVC3 file. I removed NinjectHttpApplication from my global.asax and made it back into a regular HttpApplication. When I tried to build, I get; "Exception has been thrown by the target of an invocation"

Custom Role Provider using DI ninject throwing error

百般思念 提交于 2019-12-20 00:20:10
问题 I setup a CustomRoleProver as: public class CustomRoleProvider : RoleProvider { private readonly IRepository<User> _repository; public CustomRoleProvider(IRepository<User> repository) { _repository = repository; } ... In my Global.asax.cs I have: //Create Ninject DI kernel var kernel = new StandardKernel(); kernel.Bind<IRepository<User>>().To<Repository<User>>(); //Tell ASP.NET MVC 3 to use our Ninject DI Container DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); When I

Ninject “No parameterless constructor defined for this object.”

大憨熊 提交于 2019-12-19 19:46:11
问题 I'm testing Ninject, but following the how-to, i find it impossible to make it work. The information on the web is so messy even contradictory. I'm developping a website in MVC 4 on visual studio 2012 and i did install Ninject using Nuget. So I get an error : "No parameterless constructor defined for this object.". As soon as I enter my controller. I did the necessary steps : Nuget installation in NinjectWebCommon.cs, I did register my Interface in the RegisterServices method. In my

Ninject “No parameterless constructor defined for this object.”

谁都会走 提交于 2019-12-19 19:44:42
问题 I'm testing Ninject, but following the how-to, i find it impossible to make it work. The information on the web is so messy even contradictory. I'm developping a website in MVC 4 on visual studio 2012 and i did install Ninject using Nuget. So I get an error : "No parameterless constructor defined for this object.". As soon as I enter my controller. I did the necessary steps : Nuget installation in NinjectWebCommon.cs, I did register my Interface in the RegisterServices method. In my

Error loading Ninject component ICache

偶尔善良 提交于 2019-12-19 17:37:27
问题 I am using ninject in an asp.net web api project and have started receiving this intermittent ninject error: " Error loading Ninject component ICache No such component has been registered in the kernel's component container. " I'm using: Ninject 3.0.1.10 Ninject.MVC3 3.0.0.6 Ninject.Web.Common 3.0.0.7 They are all brought into my project with NuGet I load my Modules in IocConfig.RegisterIoc and have made no other changes or tweaks. It may be unrelated but the problem started occurring at

Can't get Ninject to dispose object in Request Scope

若如初见. 提交于 2019-12-19 08:55:20
问题 I can't seem to get Ninject to dispose objects in request scope in an ASP.NET MVC application with web API no matter what I do. What I am doing: Create a new ASP.NET Web Application with Visual Studio 2013. I select the MVC template and add a Web API to it (it also has ASP.NET Identity in the package by default) I install Ninject.MVC5 package via nuget (install-package Ninject.MVC5) I add a the following class to my application: public class SomeDisposable : IDisposable { public void Dispose(