ninject

Ninject: entity object cannot be referenced by multiple instances of IEntityChangeTracker

限于喜欢 提交于 2020-01-21 20:35:26
问题 I am starting to use Ninject in my MVC5 code-first app. Here's my NinjectWebCommon.cs: private static IKernel CreateKernel() { var kernel = new StandardKernel(); try { kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); kernel.Bind<CMSContext>() .ToSelf() //.InSingletonScope(); .InRequestScope(); kernel.Bind<IExecutiveRepository>() .To<ExecutiveRepository>(); kernel.Bind

Ninject + MVC3 = InvalidOperationException: Sequence contains no elements

百般思念 提交于 2020-01-19 04:42:49
问题 I created a new MVC3 project, hit F5, saw the sample page. Then I used NuGet to get the Ninject.MVC extension. I modified my global.asax according to the Ninject documentation, How To Setup an MVC3 Application: public class MvcApplication : NinjectHttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

Custom Membership provider & MVC 4

妖精的绣舞 提交于 2020-01-17 03:52:47
问题 Continue from this solution : How to configure Ninject for MVC4 & custom Membership provide? I declare public interface IUserRepository : IRepository<UserModel> { MembershipUser CreateUser(string username, ... , string providername = null); void Logout(); Boolean Login(string userName, string Password, bool persistCookie = false); bool RegisterUser(UserModel user); } And implement within UserRepository public class UserRepository : RepositoryBase<MyDbContext, UserModel>, IUserRepository {

Asp.net Core AutoFac register generic using factory

家住魔仙堡 提交于 2020-01-15 04:58:07
问题 I'm using Asp.net Core with AutoFac and following the accepted answer here: Validation: How to inject A Model State wrapper with Ninject? This uses ninject. I don't understand how to do the equivalent of this ninject part in autoFac, specifically the kernel.Get : Func<Type, IValidator> validatorFactory = type => { var valType = typeof(Validator<>).MakeGenericType(type); return (IValidator)kernel.Get(valType); }; kernel.Bind<IValidationProvider>() .ToConstant(new ValidationProvider

Asp.net Core AutoFac register generic using factory

99封情书 提交于 2020-01-15 04:58:05
问题 I'm using Asp.net Core with AutoFac and following the accepted answer here: Validation: How to inject A Model State wrapper with Ninject? This uses ninject. I don't understand how to do the equivalent of this ninject part in autoFac, specifically the kernel.Get : Func<Type, IValidator> validatorFactory = type => { var valType = typeof(Validator<>).MakeGenericType(type); return (IValidator)kernel.Get(valType); }; kernel.Bind<IValidationProvider>() .ToConstant(new ValidationProvider

Ninject WCF Garbage Collection on repositories

巧了我就是萌 提交于 2020-01-14 14:37:50
问题 I'm using Ninject 2.2 with the WCF extension. On most of my services the repositories are instantiated/released quickly. However, one of my services performs long-running operations (2-3 min). If I watch the w3wp process I can see the TCP/IP connections being established with SQL and I can run sp_who2 on SQL and see the connections. When these operations are complete, the connections remain open for 5-10 minutes. I don't see new connections being spawned when I run the operation multiple

Why would my asp.net-mvc site using nhibernate simply stop doing updates and deletes?

断了今生、忘了曾经 提交于 2020-01-14 14:28:32
问题 I have a very simple CRUD asp.net-mvc site that uses nhibernate to interface with a mySQL db. I am using the UnitOfWork and Repository patterns. After upgrading to MVC 4 and the latest nhibernate and mySQL versions (via nuget) I am suddenly seeing a weird issue where updates and deletes have stopped working. Here is an example Delete code in my controller that stopped working: public ActionResult Delete(int id) { MyEvent c = _eventRepository.FindBy(id); _unitOfWork.Begin(); _eventRepository

Ninject throws Activation Exception in a WebApi project with multiple assemblies

大城市里の小女人 提交于 2020-01-14 10:23:08
问题 My asp.net WebApi project comprises of multiple assemblies for Services, Core and Data Access. In an attempt to use Ninject as my DI container in the project, I added Ninject.Web.Common package from NuGet. Then, I Implemented IDependencyResolver as: public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver { readonly IKernel kernel; public NinjectDependencyResolver(IKernel kernel) : base(kernel) { this.kernel = kernel; } public IDependencyScope BeginScope() { return

Ninject throws Activation Exception in a WebApi project with multiple assemblies

百般思念 提交于 2020-01-14 10:23:07
问题 My asp.net WebApi project comprises of multiple assemblies for Services, Core and Data Access. In an attempt to use Ninject as my DI container in the project, I added Ninject.Web.Common package from NuGet. Then, I Implemented IDependencyResolver as: public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver { readonly IKernel kernel; public NinjectDependencyResolver(IKernel kernel) : base(kernel) { this.kernel = kernel; } public IDependencyScope BeginScope() { return

Ninject throws Activation Exception in a WebApi project with multiple assemblies

可紊 提交于 2020-01-14 10:23:05
问题 My asp.net WebApi project comprises of multiple assemblies for Services, Core and Data Access. In an attempt to use Ninject as my DI container in the project, I added Ninject.Web.Common package from NuGet. Then, I Implemented IDependencyResolver as: public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver { readonly IKernel kernel; public NinjectDependencyResolver(IKernel kernel) : base(kernel) { this.kernel = kernel; } public IDependencyScope BeginScope() { return