Questions tagged [structuremap]

StructureMap is a Dependency Injection / Inversion of Control tool for .NET licensed under Apache 2.

StructureMap is a Dependency Injection / Inversion of Control tool for .NET licensed under Apache 2. It can be found at https://structuremap.github.io/.

Installation

StructureMap can most easily be installed through its NuGet package.

Install-Package structuremap

Links

Related

1728 questions
52
votes
2 answers

Comparing Castle Windsor, Unity and StructureMap

In a follow up to Krzysztof’s statement that Windsor does a lot more than other IoC’s, I wanted to understand how these IoC’s stack up against each other and the benefits/additional facilities that castle Windsor provides. Are there any…
48
votes
3 answers

Passing constructor arguments when using StructureMap

I'm using StructureMap for my DI. Imagine I have a class that takes 1 argument like: public class ProductProvider : IProductProvider { public ProductProvider(string connectionString) { .... } } I need to specify the…
Mosh
  • 5,944
  • 4
  • 39
  • 44
47
votes
2 answers

Difference between MEF and IoC containers (like Unity, Autofac, SMap, Ninject, Windsor.Spring.net, etc.)

I have been searching about the dependency injection and read a few articles. But still I am unable to find out the difference between MEF and other IoC's. So, my question is this: In which situation should I prefer to use a MEF or IoC…
38
votes
1 answer

Tell StructureMap to use a specific constructor

I have two services that require an XPathDocument. I want to be able to define named instances of XPathDocumnet to use in the configuration of the two services. I also want to be able to tell StuctureMap which constructor of XPathDocument to use.…
awilinsk
  • 2,054
  • 6
  • 31
  • 50
37
votes
2 answers

How do I use StructureMap with generic unclosed types using Scan with a "greedy" constructor

Between various Stack Overflow questions and blog posts there is a pretty reasonable amount of documentation on the topic of open generics and StructureMap. Unfortunately, I must be missing something as my attempts at using scan to perform the…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
37
votes
1 answer

How to use Container instead of ObjectFactory in StructureMap ServiceActivator?

When implementing DI in WebAPI with StructureMap, we used the ServiceActivator found in Configuring Dependency Injection with ASP.NET WebAPI 2.1 WebAPI + APIController with structureMap public class ServiceActivator : IHttpControllerActivator { …
Blaise
  • 21,314
  • 28
  • 108
  • 169
37
votes
4 answers

StructureMap singleton usage (A class implementing two interface)

public interface IInterface1 { } public interface IInterface2 { } public class MyClass : IInterface1, IInterface2 { } ... ObjectFactory.Initialize(x => { x.For().Singleton().Use(); …
James
36
votes
4 answers

Ways of keeping configuration code out of logic code using Dependency Injection

How can keep all the configuration file code out of my logic code using Settings (ApplicationSettingsBase) and Dependency Injection? With configuration I mean a customer specific configuration file. Do I really have to inject a configuration class…
Rookian
  • 19,841
  • 28
  • 110
  • 180
30
votes
3 answers

How to dispose resources with dependency injection

I'm using StructureMap to resolve references to my repository class. My repository interface implements IDisposable, e.g. public interface IMyRepository : IDisposable { SomeClass GetById(int id); } An implementation of the interface using Entity…
Fixer
  • 5,985
  • 8
  • 40
  • 58
29
votes
2 answers

Configuring dependency injection with ASP.NET Web API 2.1

I'm creating an ASP.NET Web API 2.1 site and as I want to inject dependencies directly into the controllers, I've created my own implementation of IDependencyResolver so that StructureMap will handle that for me. public class…
Paul Hunt
  • 3,395
  • 2
  • 24
  • 39
27
votes
2 answers

Custom Controller Factory, Dependency Injection / Structuremap problems with ASP.NET MVC

I recently tried to implement dependency injection using StructureMap. I managed to follow the example all the way but I'm encountering a thrown exception every time I try to run the application. Here's some code snippets from my controller…
kitsune
  • 11,516
  • 13
  • 57
  • 78
27
votes
10 answers

How to scan and auto-configure profiles in AutoMapper?

Is there any way to auto-configue Automapper to scan for all profiles in namespace/assembly? What I would like to do is to add mapping profiles to AutoMapper from given assembly filtered by given interface, something like Scan Conventions in…
Wojciech Markowski
  • 1,074
  • 1
  • 11
  • 15
25
votes
5 answers

Structuremap, AutoFac, or Ninject, which one is great for a large scale web app?

I have some experience in working by Structuremap. And now I'm creating a big and large scale web app (really a social networking site) using ASP.NET MVC 3, Entity Framework 4.1 code-first, SqlServer 2008, via C#.NET 4. Which one of Structuremap,…
amiry jd
  • 27,021
  • 30
  • 116
  • 215
24
votes
9 answers

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily

I am new to StructureMap. I have downloaded and am using version 2.6.1.0. I keep getting the below error: StructureMap Exception Code: 202 No Default Instance defined for PluginFamily Company.ProjectCore.Core.IConfiguration, …
Peter
  • 5,251
  • 16
  • 63
  • 98
23
votes
5 answers

Automatically resolve Interface to Implementation in StructureMap (differ only by generic type T)

I have an interface (IRepository) that is currently being extended for each specific repository, ie: IUserRepository : IRepository. Each of these interfaces has corresponding concrete classes, ie: UserRepository : Repository,…
Michael Shimmins
  • 19,961
  • 7
  • 57
  • 90
1
2 3
99 100