Questions tagged [ninject]

NInject is a dependency injection framework for .NET applications.

Filter by
Sorted by
Tagged with
0votes
0answers
26views

DI inject different concrete class depending on scope of parent class

I've just identified a bug in my ASP.NET Web Forms application where a Request Scoped service (ServiceA) was being injected into a singleton service (ServiceB) with the adverse effect that stuff using ...
user avatar
  • 3,255
0votes
0answers
33views

Ninject - Binding multiple interfaces to a provider or a method given a runtime context?

The Goal I wish to bind configuration interfaces given context only known at runtime. The Context The service monitors a directory for xml transaction files. The file name contains the company ...
user avatar
0votes
0answers
17views

How to use Ninject DefinesNamedScope vs InNamedScope?

I'm very incredible difficulties understanding the difference between Ninject DefinesNamedScope and InNamedScope. Perharps my understanding of scope is wrong?! I'm trying to use a group of instances ...
user avatar
0votes
0answers
25views

Ninject.Extensions.Conventions error "Binding specified without Scope"

I have a bunch of classes that use the same interface, and I want to bind them all. I'm using this code, using Ninject.Extensions.Conventions kernel.Bind(x => x.FromThisAssembly() ....
user avatar
  • 1,432
0votes
1answer
163views

Ninject just won't register MediatR.IRequestHandler<,> using convention-based binding?

As per following example: MediatR.Examples.Ninject I've a MediatorModule class as follows: public class MediatorModule : NinjectModule { public class ContravariantBindingResolver : ...
user avatar
0votes
1answer
53views

Having some parameters Injected with DI and some assigned manually

In a .NET Core 3.1 console application I want a Class that would have some parameters in constructor injected but some that I could assign manually. For example something like that but with ...
user avatar
  • 1
1vote
0answers
23views

How to implement dependency in ScheduledTask inheritances (Telerik Sitefinity)

please give me some advice. My problem is the following, I'm implementing a dependency in a custom scheduled task. The task itself is initialized with the necessary dependency, however, during the ...
user avatar
  • 11
0votes
1answer
29views

What Ninject convention should I use to bind all interfaces starting with "I" with interfaces having the same name without the "I" prefix for COMObj?

I'm working on integrating an accounting system which objects are COM objects. When binding one to one as follows, it works just fine. IKernel kernel = new StandardKernel(); kernel.Bind<IAcoSDKX>...
user avatar
0votes
0answers
71views

How to use Ninject Dependency Injection to a Custom Authentication Filter for WebApi in ASP.NET MVC 5?

I have an AuthenticationFilter for WebApi to check credentials to use for basic authentication. The credentials are stored in the database. Im trying to avoid the use of [inject] for property ...
user avatar
  • 4,612
0votes
0answers
13views

Share the same intances between Ninject InterceptAttribute and ApiController, in request scope

I´m using InterceptAttribute (Ninject.Extensions.Interception.Attributes) to proxy my service classes and add some extra functionality before executing a method. For example: public class ...
user avatar
0votes
0answers
189views

How to use Services and HttpContext in Serilog Enrichers in ASP.NET

In my Current Application i.e .NET Core i am using Serilog enricher and i am able to access services and httpContext using DI. But how can i achieve the same in ASP.NET web application? I ASP.NET i am ...
user avatar
1vote
1answer
20views

Ninject how to prevent shared objects

I have a binding like the following in my kernel kernel.Bind<IMyDependency>().To<MyDependencyImplementation>(); In a single app domain, we multiple calls to kernel.Get<IMyDependency>...
user avatar
  • 3,349
0votes
0answers
49views

Ninject Serilization error when calling new StandardKernel

When I try to call var ninjectKernel = new StandardKernel(); I get the below error. I can successfully use ninject with constructor injection. I only get this error when I try to grab a service by ...
user avatar
  • 9,089
0votes
1answer
89views

How to Use Ninject with MVVM and WPF

I'm struggling to build an App using WPF and MVVM pattern. In this App I have three buttons in the MainView - Camera, Boiler, Temperature Sensor. When I press a certain button, It opens additional ...
user avatar
1vote
1answer
36views

Ninject disposes child object before disposing the parent that uses it

When I call IKernel.Dispose() in the [TestCleanup] method of my DataTest, my application is crashing because the first object to be disposed is still in use by another object. This code reproduces the ...
user avatar
  • 46
0votes
1answer
32views

How Can I Resolve Other Dependencies within Ninject .OnActivation?

I am using Ninject to set up bindings for a class which is an IObservable. I have set up a rebind to ensure that the IObservable has it's IObserver subscribed as follows... kernel.Rebind<...
user avatar
0votes
1answer
34views

Multiple Binding and Contextual Binding with Ninject and MVVM

I have an Interface which take data from local Json file on startup (Deserialized) This Interface is Injected to 3 Features With Contextual Name Binding, all 3 Features run correctly as I expected ...
user avatar
  • 1
0votes
0answers
43views

Correct way to inject mapper and repositories

Following is the code from ASP.NET MVC for dependency injection. I wanted to make clear what will be the better way to inject mapper along with repositories? Will it be correct way to inject mapper? ...
user avatar
  • 83
0votes
0answers
140views

An error occurred when trying to create a controller of type 'xxx'. Make sure that the controller has a parameterless public constructor. Ninject

I am working in .Net framework 4.7.2. I am facing a problem while using NInject dependency injection resolver. I am getting the following error when trying to access NotificationController, which has ...
user avatar
0votes
2answers
75views

Ninject Dependency Injection - Two Concrete classes

I am learning Ninject for dependency injection and have a use case where two classes implement the same interface in a WPF MVVM applicaiton. In my research the dependencies can be bound using ...
user avatar
  • 310
-1votes
1answer
80views

Inject Dependency without using Constructor injection using Ninject - Unit Tests

I am creating Unit Tests for existing .NET Framework 4.5 API project. The existing project has parameterless constructor by design and dependency injection was implemented as per the class below using ...
user avatar
  • 165
0votes
0answers
13views

Is this an acceptable way to let Autmapper work together with Ninject?

I am using Automapper 10.1 and Ninject 3.3.4 in a standard ASP.NET MVC 5 application. I couldn't really get it done with the AutoMapper documentation, so.. Here I register IMapper. /// <summary> ...
user avatar
2votes
1answer
94views

how to register NodaTime.ZonedClock with Autofac

It is possible to register NodaTime.SystemClock like this: builder.Register(_ => SystemClock.Instance).As<IClock>().SingleInstance();, according to Pac0's comment here. How do I do the same ...
user avatar
  • 90
0votes
0answers
45views

How to get Ninject to deactivate the scope-defining object when using the NamedScope extension?

I have a Windows Forms application where I'm using Ninject with the Program.Main() entry point as the composition root. I have a main form of type Form1 that I create in transient scope. That form ...
user avatar
0votes
1answer
49views

Dependency Injection Ensure that you have not accidentally loaded the same module twice

I am using Ninject for Dependency Injection. I have to call two identical classes in the constructor. public EsyonluAntennaManager( IModbusActuatorService dksEkbService1, IModbusActuatorService ...
user avatar
0votes
0answers
26views

Windows Community Toolkit IoC :: Is it || Will it be capable to add IoC Modules by other vendors or its own ones?

Is Windows Community Toolkit IoC anyhow capable to receive pre-configured modules by NInject, for example ? DryIoC is having modules on its roadmap so maybe that will become also neat so that we can ...
user avatar
  • 81
0votes
1answer
31views

Resolve binding without instatiating object in Ninject

I have interface (e.g. IMyInterface). I need to get of which type object will be created if I call kernel.Get<IMyInterface>(). Not the instance of IMyInterface but the type of instance without ...
user avatar
0votes
1answer
29views

Is it possible to rebind an IPrincipal in a CustomAttribute?

Background We have a Web API 2 project that we are making into our "public api". On requests to our api, we are using a custom attribute (ApiKeyAuthorize) finds users based on an API Key and ...
user avatar
  • 2,068
0votes
1answer
33views

Ninject Circular Dependencies

there are 2 classes in wpf app First class public class Context1 : BaseContext { private readonly Page1 _page1; public Context1(Page1 page1) { _page1 = page1; ...
user avatar
  • 27
0votes
1answer
47views

Ninject IOC bindings and StackOverflowException

So I currently have a straightforward service like so: public class ServiceA : IServiceA { public ServiceA() { } } And it's binded like so and works as expected. <bind service="...
user avatar
  • 1,570
1vote
0answers
35views

Blazor namedscope dependancy injection

Creating named scoped instances in constructor works in Blazor and WPF. But using IResolutionRoot to create instance only works in WPF. In the sample code WPF works perfectly, the Guid properties ...
user avatar
  • 111
0votes
2answers
93views

Ninject 4.0.0-beta-0134 throws 'A cyclical dependency was detected between the constructors of two services'

Today I updated our Ninject dependency from 3.3.4 to 4.0.0-beta-0134, but now it throws a circular dependency exception in decorator pattern: `Unhandled Exception: Ninject.ActivationException: Error ...
user avatar
0votes
1answer
72views

In memory Web API integration tests mocking out controller dependencies with Ninject

I have a Web API 2 application I would like to add some tests hosting the server in memory. I have this configuration in my tests. public BaseServerTests() { var fake = ...
user avatar
  • 866
0votes
1answer
193views

Rdlc report unable to parse regular expression

I am using the .net framework 4.7.2. And In a web API project with Ninject dependency injection, I am trying to generate an rdlc report with an expression. The problem is the report is generating ...
user avatar
  • 188
0votes
1answer
55views

Can I inject specific parameters with Ninject when a class is instantiated?

For the sake of this example, I have a "User" class that needs to receive access to my EmailService. Whenevera a new user instance is created ( var user = new User(emailServiceInstance); ) ...
user avatar
  • 4,242
0votes
1answer
45views

Why am I getting MissingMethodException even though I inject dependencies with ninject?

When I try to access the Exams view, I get this error. I don't understand, because everything seems to be ok. Error: [MissingMethodException: No constructor without parameters has been defined for ...
user avatar
0votes
1answer
128views

Ninject Data injection in ASP.NET MVC project

I'm developing a web app that uses Ninject Data injection in my ASP.NET MVC5 project. I set up an NinjectDependencyResolver that inherits from IDependencyResolver like this: public class ...
user avatar
  • 139
1vote
0answers
49views

Correct way to mock using DI for dependent classes

I have a situation in a C# code where there are 2 classes or even more classes, where 1 class is dependent on another and so on. And I am using DI using ninject. So now I am trying to mock a class but ...
user avatar
  • 108
0votes
1answer
358views

Dependency Injection in ASP.NET Web API (Ninject)

I need to implement DI in my Web API Project. I'm using a Ninject and got a little problem. This is Global.asax: public class WebApiApplication : System.Web.HttpApplication { protected void ...
user avatar
  • 13
0votes
1answer
80views

Autofac equivalent of NInject's ToMethod() with open generics

I'm trying to migrate to Autofac from NInject, and I'm running into a seemingly simple problem. I want to migrate this NInject binding: Kernel.Bind(typeof(IOptions<>)).ToMethod(c => ...
user avatar
  • 12.6k
0votes
2answers
681views

Could not load type 'Ninject.Web.WebApi.IWebApiRequestScopeProvider' from assembly 'Ninject.Web.WebApi'

I've recently upgraded my solution to .net Framework 4.8 and updated a load of nuget packages and now I'm having problems getting my API project to launch. I felt this smelled of bad binding redirect, ...
user avatar
0votes
1answer
179views

there are no "Ninject.Web.Common.OwinHost" and "Ninject.Web.WebApi.OwinHost" in nuget

I want to create an ASP.NET WebAPI project with Ninject, I usually referenced Ninject OWIN based DLLs, but I cannot find "Ninject.Web.Common.OwinHost" and "Ninject.Web.WebApi.OwinHost&...
user avatar
1vote
0answers
142views

C# Ninject not injecting on deserialize from JSON

I'm writing a simple windows service, and I want to use a Dependency Injection. On service start, the app read the JSON string from file, and deserialize it to object. One of property in JSON is list ...
user avatar
0votes
1answer
47views

C# and Ninject question, Inheriting a class runs a method, but how does this happen behind the scene?

I can't seem to find the right answers in several related questions here. I'm learning Ninject from an article (created a console app in C#), I created a class I named DILoader and inherited ...
user avatar
0votes
0answers
47views

Abstract factory to use inject properties c# ninject

I have an Abstract factory like this: public abstract class CustomFactory { [Inject] public ICustomService service{ get; set; } } Every time when I try to access service, I get null. Service ...
user avatar
0votes
0answers
397views

Using Dependency Injection in Blazor WebAssembly

I need use dependency injection in Blazor WebAssembly app. But there is a situation, my blazor app in UI layer. I will inject dependency from business layer and I need inject data layer too. But UI ...
user avatar
6votes
0answers
259views

InRequestScope acting like InTransientScope

I have an ASP.NET Web Application (.NET Framework 4.8) in which I've set up NInject but any services I set up with InRequestScope are coming through as if transient scope (i.e. new instances are ...
user avatar
  • 3,255
1vote
1answer
86views

Using Ninject as the DI Container with Calburn.Micro and MVVM in WPF

All I have some experience with Caliburn.Micro using System.ComponentModel.Composition as an IoC container. This time I want to have some fun and use Niject. To setup the Calburn.Micro bootstrapper, I ...
user avatar
2votes
1answer
129views

.NET Standard + .NET Framework: could not load file or assembly 'Ninject'

SITUATION I have the following solution structure: - solution - "WPF Client" PROJECT[.NET Framework 4.6.1] (has ref to: "Core Logic" PROJECT, "Service Provider&...
user avatar
1vote
1answer
91views

ASP.NET MVC 5 + EF6 + Ninject - Multitenancy Database

I have a business ASP.NET MVC5 application where each customer has his own database. I want to use EF6 and Ninject for DI. For login I'm using ASP.NET Identity. For each user exists a UserClaim where ...
user avatar
  • 173

15 30 50 per page
1
2 3 4 5
78