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
2 answers

How do i get MEF container to inject himself

I'm using constructor injection with MEF Composition Container and I want to know how can I make the CompositionContainer inject itself on the instance of the object he is providing.
Leonardo
  • 10,737
  • 10
  • 62
  • 155
1
vote
1 answer

How to denote component lifetime when using convention-based registration?

I've read a lot on the subject of IoC containers and particularly Mark Seemann's blog posts, where he emphasises the importance of convention over configuration. I understand and agree with his point, but I wonder how best to mark out a class for an…
Alex
  • 7,639
  • 3
  • 45
  • 58
1
vote
1 answer

Autofac, IoC & Separation of Layers

In my ASP.NET MVC 4 c# project I have 3 layers. Data, Business and Web. I follow repository pattern and services. I use Autofac for dependency injection. What I did was registering components in global.asax. By this way, I had to reference my Data…
1
vote
2 answers

How to discover the underlying Implementation Type of a decorated instance when calling GetAllInstances?

I have this code: using (container.BeginLifetimeScope()) { RenderWord instruction = new RenderWord(); var instances = container.GetAllInstances>(); var firstInstance = result.First(); } instances is of…
qujck
  • 14,388
  • 4
  • 45
  • 74
1
vote
0 answers

Ninject not disposing objects mapped as InRequestScope if they reference objects mapped as InSingletonScope

I have several Repository classes that are mapped as InRequestScope so that they are cached for the lifetime of the request. These Repository classes are injected with a CacheClass that is mapped as InSingletonScope. It seems that because the…
Ibraheem
  • 2,168
  • 20
  • 27
1
vote
3 answers

StructureMap Error 202 Setting up IOC container

I'm getting an error: StructureMap Exception Code: 202 No Default Instance defined for PluginFamily MVCPoco.Services.IService, MVCPoco.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Line 96: { Line 97: Type…
Diego
  • 11
  • 2
1
vote
2 answers

InjectableFilterAttribute never hits the Filter

On my base controller I have placed the Logger attribute. This LoggerAttribute looks like this: public class LoggerAttribute: InjectableFilterAttribute { public override Type FilterType { get { return typeof (LoggerActionFilter); } …
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
1
vote
0 answers

IOC from outside ServiceStack

I am using ServiceStack with SignalR. I am trying to access the database orm but my DBFactory.OpenDBConnection is not not being found. I can do this inside of service stack (ie from an api call) but when I enter via a SignalR hub IOC is not…
Jeff
  • 2,061
  • 4
  • 27
  • 45
1
vote
1 answer

Lifetime management in mvc turbine?

How can I manage the lifetime of my services in mvc turbine (using Unity)? I have an ISearchService implementation LuceneSearchService that takes an IConfigurationService and ILoggerService. Currently my searchservice registration looks like…
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
1
vote
2 answers

Why does this registration cause StructureMap to throw Error 104

I would like to be able to resolve an enumerable collection of IRepository where T : IDocument In my registry class I've added the following registration…
Jason
  • 15,915
  • 3
  • 48
  • 72
1
vote
1 answer

Where is the place for dependencies resolving using IoC within WPF app?

I have read in "Dependency Injection in .NET" by Mark Seemann that there should be a single place (per each) where Register, Resolve and Release have to be called. Now, I'm trying to set up the environment of a new WPF project. Our team has decided…
EngineerSpock
  • 2,575
  • 4
  • 35
  • 57
1
vote
2 answers

RunTime Data for dependency injection?

I have the following interface public interface ISender { void SendMessage(string msg); } along with the following implementation public class EmailSender : ISender { private EmailSettings _emailSettings; …
1
vote
1 answer

How to correctly use SimpleInjector - RegisterAllOpenGeneric

I'm unable to figure out the correct way to use RegisterAllOpenGeneric I have these simple definitions: public interface ISubscribeTo { } public class AnEventOf { } public interface IMarker { } public class PocoB : IMarker { } and a normal…
qujck
  • 14,388
  • 4
  • 45
  • 74
1
vote
1 answer

Why IoC Containers(e.g. Unity, and so on.) pick the constructor with the most parameters first?

What the drawbacks when they pick the constructor with the less parameters first? Best regards.
Jack Hu
  • 1,315
  • 2
  • 13
  • 27
1
vote
1 answer

Architecture with IoC Containers and Composition Root

I'm quite new to DI and IoC Containers. I understand that the IoC container should only life at the composition root of the project. And I understand that all other projects in the solution shouldn't have a reference to the IoC container. So far so…