Questions tagged [light-inject]

An ultra lightweight single file Inversion of Control container for the .Net framework.

An ultra lightweight single file Inversion of Control container for the .Net framework. Use attributes to control injected dependencies. LightInject has full support for the new Windows Runtime making it a perfect choice for Windows Store Apps. Implement cross cutting concerns using the AOP capabilities of LightInject.

LightInject provides two distribution models via NuGet

96 questions
3
votes
2 answers

Specify lifetime when registering services in LightInject while passing constructor parameters?

Using LightInject, lets say that I have a service that I want registered with multiple constructor parameters, example: container.Register>( (factory, arg1, arg2, arg3) => new Foo(arg1, arg2,…
cganickel
  • 76
  • 6
3
votes
1 answer

Unity has CreateChildContainer, is there equivalent in SimpleInjector or LightInject

We're in the process of evaluating SimpleInjector and LightInject to replace our current Unity implementation in our application. Unity has a method that allows a hierarchy of containers with a call to CreateChildContainer(). Is there an equivalent…
Ray
  • 4,679
  • 10
  • 46
  • 92
2
votes
0 answers

Lightinject optional property injection

I would like consumers of my nuget package to be able to inject an optional IConfiguration implementation. I'm using it along with Umbraco, so it's wired up automatically with Lightinject 5.4. I've created a property with the optional…
Johan
  • 35,120
  • 54
  • 178
  • 293
2
votes
0 answers

How to use LightInject with Web Forms?

I have a legacy ASP.Net Web Forms application targeting .Net 4.8 in which I would like to use dependency injection. Our engine of choice is LightInject. With the help of this answer and the source code of ContainerServiceProvider.Cs from the…
2
votes
0 answers

LightInject register generic with parameters?

I have Interface IRepository and Class Repository with parameter constructor which Implement IRepository. Both Class and Interface are generic. I want to pass this parameter while registering. The code is as follows: public interface…
Joker_37
  • 839
  • 2
  • 8
  • 20
2
votes
1 answer

LightInject GetInstance returning that cannot be used with type arguments

I'm new to dependency injection and I find LightInject to start. So I created 2 interfaces and implemented those interfaces into 2 classes. Now, I want to get a instance of Payment but compiler keeps saying that non-generic method…
2
votes
1 answer

Using LightInject to register all classes that implement a generic interface

I can't figure out how to use LightInject's API to register all handlers defined in a given class. In this case, defining handlers for Rebus using the LightInject adapter. So given a handler defined as: public class MyHandler :…
2
votes
0 answers

LightInject - No parameterless constructor defined for this object in .net core

I am having trouble retrieving an instance using lightinject and .net core. Originally this was a comprehensive set of classes etc. but I've simplified it. In my startup class, ConfigureServices method I have the following code; var container =…
2
votes
0 answers

ASP.Net Core Dispose vs Per Request Lifetime

So I am working on a simple project that utilizes an api layer, services layer (think business logic) and all the appropriate supporting layers around it. In the past I believe Web Api 2 requests would kick off the disposal hierarchy when the…
Shawn
  • 869
  • 1
  • 9
  • 27
2
votes
1 answer

LightInject doesn't resolve inherited generic types

I'm trying to use LightInject and MediatR to build generic request handlers. Basically, I have types like the following: public class SomeType { } public class InheritedType : SomeType { } public class Handler : IAsyncRequestHandler
agc93
  • 663
  • 1
  • 7
  • 19
2
votes
1 answer

Web app performance not improved significantly while migrating from Ninject to LightInject

We have a production web application (ASP.NET MVC). The application was developed 2 years ago and used Ninject as DI Container. Looking at performance results, we got motivated to replace Ninject with LightInject. We have done that in other small…
SBirthare
  • 5,117
  • 4
  • 34
  • 59
2
votes
0 answers

ASP.NET MVC: No parameterless constructor defined for this object with Lightinject

I have started using LightInject, but getting No parameterless constructor defined for this object error. The code as below, Global.asax.cs: protected void Application_Start() { AreaRegistration.RegisterAllAreas(); …
2
votes
2 answers

Resolve object using DI container with object instance

I have a ICommand interface and tasks that are using dependencies injected by constructor. Dependencies are using different constructors so they have to be resolved by the request itself. I want to tell my container how to resolve some dependencies…
Ryszard Fiński
  • 452
  • 3
  • 7
2
votes
1 answer

FluentValidation in Lightinject

I'm using fluentvalidation and lightinject Here is my code to insert a blog article; public OperationResultDto Add(BlogArticleDto blogArticleDto) { OperationResultDto result = new OperationResultDto(); ValidationResult…
2
votes
1 answer

Auto registration of dependencies with LightInject

I'm using LightInject as a IoC container for my class library project. As these projects type do not have any entry point or startup methods where i can write the code for registering the dependencies. I want to implement something auto registration…
MAQ
  • 443
  • 7
  • 15