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
15
votes
3 answers

DI/IoC Container Performance Benchmark Comparison?

I've found some 2008 benchmark results for testing the performance of several of the top .NET DI/IoC containers here. But I haven't been able to find any updated results. Are there any benchmarks out there that compare some of the big IoC…
David Hoerster
  • 28,421
  • 8
  • 67
  • 102
15
votes
1 answer

StructureMap not possible to use injected instance for setter injection

I am having a problem with injecting an instance into structuremap for my tests. My objects graph looks like this internal class ConfigurationManager : IConfigurationManager : IManager { public ISomeManager SomeManager { get; set; } } internal…
15
votes
1 answer

What is the difference between HybridHttpOrThreadLocalScoped & HttpContextScoped

Simply, what is the difference between HybridHttpOrThreadLocalScoped & HttpContextScoped?
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
15
votes
4 answers

How to inject AutoMapper IMappingEngine with StructureMap

Most of the examples I've found for Automapper use the static Mapper object for managing type mappings. For my project, I need to inject an IMapperEngine as part of object construction using StructureMap so that we can mock the mapper in unit tests…
Jay Walker
  • 4,654
  • 5
  • 47
  • 53
14
votes
3 answers

What is the Best Way to Organize a ASP.Net MVC Solution Using Dependency Injection?

I am early in development on a new ASP.Net MVC project and I using this project to get into DI. I'm pretty sure that I am going to go with Structure Map, but that isn't what I am asking about. What I am trying to figure out is how best to organize…
14
votes
1 answer

StructureMap not recognising TheCallingAssembly

am kinnda new to IOC and StructureMap. WHen i am trying to call the TheCallingAssembly() method, its not recognising it. Someone please help ObjectFactory.Configure(x => { x.Scan(y => { …
kayze
  • 738
  • 8
  • 19
  • 33
14
votes
1 answer

StructureMap and the decorator pattern

I'm using StructureMap, v. 2.5.3 and am having trouble with chaining together implementations on an interface to implement the Decorator pattern. I'm used to Windsor, where it is possible to name variations on interface implementations and send the…
iammaz
  • 211
  • 1
  • 10
13
votes
3 answers

Inject different implementations of an Interface to a command at runtime

I have an interface in my project that 2 classes implement it: public interface IService { int DoWork(); } public class Service1:IService { public int DoWork() { return 1; } } public class Service2:IService { public int…
Masoud
  • 8,020
  • 12
  • 62
  • 123
13
votes
5 answers

WebActivator.PreApplicationStartMethod does not work

[assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.App_Start.StructureMapMvc), "Start")] namespace MyApp.App_Start { public static class StructureMapMvc { public static void Start() { var container =…
Maneeshpal
  • 179
  • 1
  • 1
  • 7
12
votes
4 answers

Structuremap does not work on MVC4

I've used StructureMap in MVC2/3 many times without any concern, but I guess handling IoC is different in MVC4. When i used StructureMap for handling IoC in MVC4 I get the following exception.: No parameterless constructor defined for this…
12
votes
1 answer

NLog GetCurrentClassLogger() NullReferenceException using StructureMap (Full Trust)

It seems like NLog can't use reflection for GetCurrentClassLogger(), even though my MVC 3 app is deployed in a Full Trust environment on IIS7. I'm using StructureMap 2.6.1 and the problem seems to appear sporadically between deploys. I can't figure…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
12
votes
6 answers

swagger UI is not showing anything in webapi

I followed this up to the xml doc part in order to create Swagger documentation using Swashbuckle. It should allow me to view the endpoints via (in my case): http://localhost:51854/swagger/ui/index Unfortunately, I cannot see any endpoints: Any…
cs0815
  • 16,751
  • 45
  • 136
  • 299
12
votes
1 answer

Named Instances and a Default Instance in StructureMap?

In my StructureMap bootstrapping code I'm using a custom convention to scan assemblies and add interface/implementation pairs to the object graph as named instances. Essentially I have some logic which checks configuration settings and drills down…
David
  • 208,112
  • 36
  • 198
  • 279
12
votes
4 answers

Structuremap, constructor that takes a list of plugins

I got an interface like this public interface IWriter { ... } and a class public class WriterMerger { public WriterMerger(IEnumerable writers) ... } I want structuremap to fill out the constructor argument on WriterMerger with all…
AndreasN
  • 2,881
  • 3
  • 24
  • 29
12
votes
7 answers

How to pass arguments to a constructor in an IOC-framework

How can I pass arguments to a constructor in an IOC-framework? I want to do something like: (Trying to be IOC-framework agnostic ;) ) object objectToLogFor = xxx; container.Resolve(objectToLogFor); public class MyLogging : ILogging { …
Ruben
  • 6,367
  • 1
  • 24
  • 35