Questions tagged [ninject]

NInject is a dependency injection framework for .NET applications.

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

How to pass Dispatcher to a class through constructor by Ninject

I have a class which takes a parameter of type Dispatcher: public class MessagesViewModel { private readonly DispatcherTimer keepAliveTimer; public MessagesViewModel(Dispatcher dispatcher) ...
amin mohammadi's user avatar
0 votes
1 answer
149 views

WPF with Dependency Injection using Ioc

I am currently learning how to code in WPF desktop application, and I am following this show a super old tutorial on youtube on the subject: https://www.youtube.com/watch?v=w5kAUCFDRy4&list=...
Jorge Jurado-Garcia's user avatar
0 votes
0 answers
63 views

C# Ninject IIS express - continually loading/unloading

We have .net4 web app running - pretty standard monolith architecture, Api to service to repository via interfaces using Ninject for Dependancy Injection. It is now running superslow and it looks like ...
user2590928's user avatar
0 votes
1 answer
36 views

Ninject + Ninject Child Kernels + Continuous Azure WebJobs

I have an Azure WebJob containing few different functions. These functions need to be injected with some services by Ninject (using constructor injection). Since the standard JobActivator - the class ...
Marconline's user avatar
  • 1,108
0 votes
1 answer
57 views

What is the equivalent code for the ASP.NET Core DI framework from this example using Ninject and .toconstant?

I am migrating a project that used Ninject to another one that uses ASP.NET Core DI and I'm getting trouble when trying to inject this piece of code in Ninject: Bind<PlayerService....
Wrong's user avatar
  • 1,195
0 votes
1 answer
34 views

ninject and gzip response conflict

I am using this compress attribute to compress my response from web API. After adding ninject to my project, the compress attribute doesn't work correctly, and it produces some unrecognized character ...
shahab javanmardi's user avatar
0 votes
1 answer
54 views

How to reuse a new view in MVVM with Caliburn.Micro and Ninject

I am testing the possibility to modify dynamically the structure of Grid control (number of Rows/Columns for example). I am using last version Caliburn.Micro and Ninject and use a GridHelpers (i have ...
Frenchy's user avatar
  • 16.5k
1 vote
2 answers
144 views

Parameterless constructor missing - NInject Dependency Injection

I have tried to use Ninject 3 to inject "RuleChecker" into my controller, but it doesnt work. Error "Make sure that the controller has a parameterless public constructor." I have ...
Toni0123's user avatar
  • 107
0 votes
0 answers
50 views

Ninject Not Resolving Web API Dependency Injection

I have the following two classes. The ninject web common: public static class NinjectWebCommon { private static readonly Bootstrapper bootstrapper = new Bootstrapper(); /// <summary&...
Hasan Shouman's user avatar
0 votes
0 answers
85 views

Can I Use Ninject in a Blazor .NET 6 Project?

I have a Xamarin.Forms project that depend heavily in Ninject. I Want to redesign my app with Blazor +Maui but still using Ninject as a third party DI for my project so far I havent found its that ...
Enrique A. Pinelo Novelo's user avatar
0 votes
1 answer
72 views

Refactor C# Class with Generics from IUnityContainer to Ninject

I would like to move away from the Unity NuGet package for Dependency Injection and switch to Ninject since Unity is no longer being maintained. I was wondering if someone might be able to help me ...
ADH's user avatar
  • 3,021
0 votes
0 answers
22 views

Force Ninject to clear cache

I am processing objects in a loop and for each object I am loading some data from CSV files. I am disposing of the object after it has been processed but it is still kept in the heap and I am getting ...
Anca's user avatar
  • 33
0 votes
1 answer
87 views

MVC - Website crashes when browsing after sitting idle for 20 minutes, gives "The system cannot find the file specified error."

I have been wrecking my head regarding an error I keep getting in my ASP.NET MVC and EF 6 project. It is part of a large solution (18 projects) and only my project seems to be encountering an issue. ...
rientelfon's user avatar
1 vote
0 answers
64 views

Ninject InThreadScope() resolves a new class instance despite running on the same thread

At my job we have an ASP.NET MVC (.NET 4.6.2) system that uses a class called TenantService to carry tenant data around. We use Ninject to inject a reference to this class' interface into other ...
Witold Litwin's user avatar
0 votes
0 answers
35 views

Log4net get correct class and method name in logfile using Ninject

I'm converting an application to use Ninject as IoC and one of the things I need to convert is the existing Log4net implementation. The problem that I'm facing is that in the logfile (I use the ...
martijn's user avatar
  • 485
0 votes
0 answers
69 views

Net Framework WebApi Ninject Parameterless constructor error

I have a WebAPI project in .Net Framework 4.8. I want to add Ninject to this project and I am facing various issues. There are many answers on Stackoverflow but none of them could solve my error. ...
Mehmet Serkan Ekinci's user avatar
0 votes
0 answers
93 views

Ninject exception when using named, lazy-loaded bindings

I've been using Ninject to handle my dependency injection needs, and it works quite well for my purposes. But now I'm running into a problem. Some of my bindings contain circular dependencies, so I ...
MegaJar's user avatar
1 vote
1 answer
86 views

Inject right object depending on method parameters at ninject factory namebinding

I use ninject and ninject factory extension as follows: I created two interfaces, the first interface is for the factory and the second is for the concrete class to be injected depending on the ...
dot's user avatar
  • 486
1 vote
1 answer
1k views

How to use Serilog with Windows Client (net6.0-windows) application

I'm trying to use Serilog and Ninjet on a C# Windows client (forms) application using .Net 6.0 Can anyone tell me how I configure Ninject so that ILogger is injected here: public partial class ...
spud's user avatar
  • 505
0 votes
1 answer
98 views

What is the DI equivalent for NInject DI?

I am currently migrating from .net4.6 which uses NInject modules. My target is to use .net6 core and its native DI. While doing so I came across a statement from NInject for which I am wondering if ...
Arun Prakash Nagendran's user avatar
0 votes
0 answers
89 views

Ninject is not injecting, returning Null and NullReference Exception

I'm new with this kind of technology. Been trying to resolve this issue for days now, tried all possible answers here in stack but still can't get my issue fixed. When I run my code on my local ...
Joshua Bernardo's user avatar
1 vote
0 answers
40 views

Ninject Binding Conditionally When Injecting To A Generic Interface

I have the following code structure which I want to compose with Ninject: ICommandHandler<FindAssetById, Asset> handler = new SecurityCommandHandlerDecorator<FindAssetById, Asset>( ...
Stevenfowler16's user avatar
2 votes
1 answer
497 views

.NET register services for interface, base class and sub class dependency injection

My interface and classes public interface INoteService { SomeMethod(); } public class NoteService : INoteService { private readonly IAuthenticationService _authenticationService; public NoteService(...
melmelissa242's user avatar
3 votes
1 answer
121 views

Ninject Dependency Resolver

The client which I am calling looks like this public class CmsClient : ICmsClient { private readonly HttpClient _client; private readonly ICmsSettings _cmsSettings; public CmsClient(...
Chatra's user avatar
  • 2,971
0 votes
0 answers
184 views

Ninject UserManager to Controller ASP.NET MVC

I have this controller: public class UserController : Controller { private ApplicationUserManager _userManager; public UserController(ApplicationUserManager userManager) {...
ELOL's user avatar
  • 193
1 vote
0 answers
189 views

How do I incorporate .net IServiceCollection with Ninject dependency injection?

I have a .net 4.8 framework web api application using ninject for DI and I'm trying to include a .net standard 2.0 library that includes a few ServiceCollection extensions for dependency injection. Is ...
bryasis's user avatar
  • 11
0 votes
2 answers
340 views

Getting an IServiceProvider from Ninject

I'm currently working at a discord bot and the CommandHandler needs an IServiceProvider for the Dependency Injection but I do use Ninject does anyone know a way to retrieve a ServiceProvider from ...
Bekobiii's user avatar
1 vote
2 answers
2k views

Error after updating .NET Framework 4.6.1 to 4.8

I updated my application from .NET Framework 4.6.1 to 4.8 but I have an error loading the application. For context: This application uses the Ninject Nuget for dependency injection. This nuget ...
Luis Badel's user avatar
1 vote
1 answer
523 views

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 : ...
Will Marcouiller's user avatar
1 vote
1 answer
1k views

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 ...
Fjalee's user avatar
  • 63
1 vote
0 answers
75 views

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 ...
Sky's user avatar
  • 11
1 vote
1 answer
107 views

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>...
Will Marcouiller's user avatar
1 vote
1 answer
27 views

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>...
fahadash's user avatar
  • 3,211
0 votes
0 answers
172 views

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 ...
gh9's user avatar
  • 10.3k
0 votes
1 answer
165 views

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 ...
alexei.sorokin's user avatar
1 vote
1 answer
59 views

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 ...
John's user avatar
  • 66
0 votes
1 answer
64 views

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<...
Keith Jackson's user avatar
0 votes
1 answer
51 views

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 ...
zOe's user avatar
  • 1
0 votes
0 answers
559 views

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 ...
azhar rahi's user avatar
1 vote
2 answers
181 views

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 ...
User7007's user avatar
  • 341
-1 votes
1 answer
468 views

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 ...
tmndungu's user avatar
  • 330
2 votes
1 answer
264 views

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 ...
vicNeo's user avatar
  • 132
0 votes
1 answer
189 views

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
0 votes
0 answers
85 views

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 ...
Tommy's user avatar
  • 134
0 votes
1 answer
35 views

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 ...
Grigoriy's user avatar
0 votes
1 answer
59 views

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 ...
wilsjd's user avatar
  • 2,188
0 votes
1 answer
78 views

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; ...
Unkind's user avatar
  • 27
0 votes
1 answer
66 views

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="...
Bhav's user avatar
  • 1,977
1 vote
0 answers
56 views

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 ...
Jakub's user avatar
  • 141
0 votes
2 answers
169 views

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 ...
Wrmcodeblocks's user avatar

1
2 3 4 5
78