ninject

Automapper exception: “Missing type map configuration or unsupported mapping.”

隐身守侯 提交于 2019-12-01 15:33:05
问题 I am trying to use Ninject in an ASP.NET MVC 5 application that uses AutoMapper for mapping the Model to the View Model and vice versa. Unfortunately I get an error message that states that the type map configuration is missing. I created a Ninject dependency resolver: namespace MyNamespace.Infrastructure { public class NinjectDependencyResolver: IDependencyResolver { private IKernel kernel; public NinjectDependencyResolver(IKernel kernelParam) { kernel = kernelParam; AddBindings(); } public

Ninject and static classes - how to?

房东的猫 提交于 2019-12-01 15:08:08
问题 I have a static class and I need to inject some instances into it. A static class can have a static constructor but it must be parameterless. So, how am I supposed to injet something into it? I do not wish to create a singleton. I wish to have a static class, and one of its methods operate on an instance that should be injected. Bellow is an example of what I need. public static class AuthenticationHelper { // Fields. private static object _lock = new object(); private static readonly

Error loading EntityFramework 4.3.1

有些话、适合烂在心里 提交于 2019-12-01 14:54:02
问题 I created an MVC application in C#. I created a new project in my solution called PhoneDomain. The purpose of this is to separate my data and domain layer from the actual problem. I right clicked on the project and went to "Add Library Package Reference" and I attempted to add the EntityFramework package (version 4.3.1). It said " Operation Failed " " This package contains an init.ps1 file and needs to be installed from the Package Manager Console ". So I opened the Package Manager Console in

MVC 3 ninject custom membership context disposed error

北城余情 提交于 2019-12-01 13:14:19
I have a custom membership that uses my CustomerService to communicate with the database using EF code first (4.1) I use ninject to inject the CustomerService into my custom membership class. But when I try to validate I get a context disposed error. This is because in ninject my context, repositories and services are InRequestScope(). And because I inject the CustomerService using [inject] on a property of my custom membership and in ninject use the _kernel.Inject(Membership.Provider), it is only injected ones on startup. I read a lot of posts about this problem but can not find an answer

MVC 3 ninject custom membership context disposed error

空扰寡人 提交于 2019-12-01 11:44:58
问题 I have a custom membership that uses my CustomerService to communicate with the database using EF code first (4.1) I use ninject to inject the CustomerService into my custom membership class. But when I try to validate I get a context disposed error. This is because in ninject my context, repositories and services are InRequestScope(). And because I inject the CustomerService using [inject] on a property of my custom membership and in ninject use the _kernel.Inject(Membership.Provider), it is

Ninject model validator causing issues in medium trust

一世执手 提交于 2019-12-01 11:21:49
Using Ninject 2.2 with ASP.NET MVC 3 . I have a controller and some classes located in an external assembly which are registered by loading a NinjectModule from said assembly. The models contain some validation properties. It seems Ninject is getting a security exception when a post action is done on an action which takes a model with validation attributes. Below is the exception: "Attempt by method 'Ninject.Web.Mvc.Validation.NinjectDataAnnotationsModelValidatorProvider.GetValidators(System Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext, System.Collections.Generic.IEnumerable`1)' to

Ninject model validator causing issues in medium trust

谁说我不能喝 提交于 2019-12-01 08:23:30
问题 Using Ninject 2.2 with ASP.NET MVC 3 . I have a controller and some classes located in an external assembly which are registered by loading a NinjectModule from said assembly. The models contain some validation properties. It seems Ninject is getting a security exception when a post action is done on an action which takes a model with validation attributes. Below is the exception: "Attempt by method 'Ninject.Web.Mvc.Validation.NinjectDataAnnotationsModelValidatorProvider.GetValidators(System

FileLoadException after installing Ninject.MVC5

若如初见. 提交于 2019-12-01 08:15:46
I am trying to learn ASP.NET MVC with Adam Freeman's "Pro ASP.NET MVC 5" book. Unfortunately all projects using Ninject throw the same error An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not >handled in user code Additional information: Could not load file or assembly 'System.Web.Mvc, >Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its >dependencies. The located assembly's manifest definition does not match the assembly >reference. (Exception from HRESULT: 0x80131040) This is exactly the same problem which was discussed in this

Ninject UserManager and UserStore

倾然丶 夕夏残阳落幕 提交于 2019-12-01 08:15:21
What is the most elegant way to inject UserManager and UserStore into a controller using ninject? For example, the context can be injected like this: kernel.Bind<EmployeeContext>().ToSelf().InRequestScope(); public class EmployeeController : Controller { private EmployeeContext _context; public EmployeeController(EmployeeContext context) { _context = context; } Can ninject inject UserManager and UserStore with a one line of code into a controller?! If not, what is the easiest way? I don't want to use this: var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new

How to inject dependencies using Ninject In ASP.NET WebForm?

给你一囗甜甜゛ 提交于 2019-12-01 08:02:51
I have a fair idea of using the Repository Pattern and have been attempting to "upgrade" our current way of creating ASP .Net websites. So i do the following Create a solution with a class project called DataAccessLayer and another class project called BusinessLogicLayer . Finally a 3rd project which is my ASP .Net website (a normal site). I add a dbml file to the DAL and drag a table, then in my BLL i add an interface and a class which implements this interface: My interface namespace BLL.Interfaces { interface IUser { List<User> GetAllUsers(); } } In my class namespace BLL.Services { public