Questions tagged [ioc-container]

In object oriented languages, an inversion of control container (ioc-container) can be used for configuring and managing objects in an application.

In object oriented languages, an inversion of control container (ioc-container) can be used for configuring and managing objects in an application. The container is responsible for managing object lifecycles (creation, initialization, destruction) and configures objects by wiring them together.

Objects managed by the container obtain references to other objects (their dependencies):

  • by explicitly asking the container, using dependency lookup methods on the container
  • automatically, because the container injects the dependencies using one or more dependency injection techniques

Frameworks that provide an ioc-container support one of these methods and often both.

The following frameworks are discussed here at Stackoverflow

For .NET:

For Java:

2163 questions
1
vote
1 answer

asp.net core build-in dependency injection long code

In our previous app we used StructureMap and we could write very little code. before every service we added the dependencies like: [SetterProperty] public IXService XService { get; set; } and in the constructor ObjectFactory.BuildUp(this); then…
1
vote
0 answers

How can I configure NServiceBus with multiple StructureMap child containers?

I have a service with handlers from several different domains. Each domain is self-contained, and I would like to use a StructureMap child container for each domain to segregate certain dependencies (notably, Entity Framework's DbContext). Note that…
Oblivious Sage
  • 3,326
  • 6
  • 37
  • 58
1
vote
1 answer

Castle Windsor, how to programmatically mimic the parameter xml syntax

Given this legacy XML configuration for Castle Windsor: #{message} #{files} ${HttpFileDownloader}
Tom DeMille
  • 3,207
  • 3
  • 23
  • 30
1
vote
2 answers

Resolve generic service

I got the following service: IRepository ..for which I've created an implementation defined as: Repository. How do I register it in autofac so that I can resolve it as: IRepository
jgauffin
  • 99,844
  • 45
  • 235
  • 372
1
vote
1 answer

How does laravel resolve dependencies based on typehinting?

I know how an Inversion of Control container works and I know how to create one myself. But I only know how to do this by utilizing register and resolve methods. I have looked in the Laravel documentation but I am stuck on trying to figure out how…
Stephan-v
  • 19,255
  • 31
  • 115
  • 201
1
vote
1 answer

MVC - Simple Injector and Attribute calling the Context (EF) Throwing exceptions

If I start my application and let it settle, it works great. However, when I debug my application and if I close the browser tab before it initializes anything and then call another like localhost:81/Home/Test, it throws an exception on retrieving…
1
vote
1 answer

Ioc Container: Dependency Injection, Dependency Lookup?

I am trying to understand Spring Framework more what I know currently, and I am referring to "Pro Spring 3" book. I came across the following section in the book as below: It says that in general IoC can be decomposed into two components viz: …
1
vote
1 answer

Does Laravel not have a factory style service container resolver?

Does the concept of a factory service exist in Laravel? I want to create a service provider that allows me to pass some additional configuration parameters. I'm used to Silex where I can use the Pimple factory method:…
bruchowski
  • 5,043
  • 7
  • 30
  • 46
1
vote
1 answer

Can not apply commission concerns to component Late bound because it appears to be a target-less proxy. Currently those are not supported

I designed a simple unit test pattern and used the moq library. But an exception is thrown when executing Container.Resolve() method. The following is the registration method for Castle…
1
vote
2 answers

Get IoC Container in xamarin.android

We are trying to implement IoC from xamarin.android in a MvvmCross project. Cannot figure out how to get type specified in IoC container into Setup.cs, of the android project (not ViewModel) Setup.cs protected override IMvxIoCProvider…
cfl
  • 999
  • 1
  • 14
  • 34
1
vote
1 answer

Unity bootstrapper for ASP.NET MVC (by convention) not able to construct interfaces in a different project

I have the structure like so: MyWork.BLL MyWork.DAL MyWork.Interfaces MyWork.Models MyWork.Web I have unity by convention setup in MyWork.Web project. It works fine when I leave Service.cs and IService.cs under MyWork.BLL. I'm trying to move…
NKD
  • 1,039
  • 1
  • 13
  • 24
1
vote
1 answer

Should I use objects passed to Constructor during Injection?

I understand one of the (maybe best) ways of using inversion of control is by injecting the dependent objects through the constructor (constructor injection). However, if I make calls to these objects outside of the object using them, I feel like I…
Otávio Décio
  • 73,752
  • 17
  • 161
  • 228
1
vote
0 answers

Accessing Windsor IoC container

I have an object that I would like to access the Windsor Container. I have done this by registering the container with the container itself. Like so: public class WindsorContainerInstaller : IWindsorInstaller { public void…
energ1ser
  • 2,703
  • 4
  • 24
  • 31
1
vote
2 answers

Windsor container components not available on first controller action

I'm using a configuration within the global.asax.cs to register the components but it looks the container hasn't been initialized yet at the first http request (HomeController > Index action) and it gives me a "The ObjectContext instance has been…
1
vote
1 answer

Unity Batch Register by convention

I'm trying to do the equivalent of the following Autofac code in Unity IoC. builder.RegisterAssemblyTypes(typeof (DataRepository<>).Assembly) .Where(t => t.Name.EndsWith("Repository")) .AsImplementedInterfaces(); This…
Seth
  • 954
  • 1
  • 15
  • 42