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

How to define a Structuremap named instance in Code

I want to create a Structuremap named instance in code, without config file I want to be able to create the instance like this: var namedInjector = ObjectFactory.GetNamedInstance("Other"); I cant define such a type in code. I have…
user81129
  • 203
  • 3
  • 8
11
votes
1 answer

How to configure ASP.NET Identity ApplicationUserManager with StructureMap

I am using asp.net identity in my project and using structuremap as DI framework. the problem is when i use constructor injection then ApplicationUserManager not configured all of it's members e.g TokenProvider, ... this is my ApplicationUserManager…
11
votes
3 answers

Why not lump all service classes into a Factory method (instead of injecting interfaces)?

We are building an ASP.NET project, and encapsulating all of our business logic in service classes. Some is in the domain objects, but generally those are rather anemic (due to the ORM we are using, that won't change). To better enable unit…
Andrew
  • 1,765
  • 2
  • 17
  • 24
11
votes
2 answers

Fake Assemblies show warnings when generating shims for Interface and stubs for sealed types

I have a build configured with CI post which some tests are run. Although the tests run successfully, the build shows warnings: : Cannot generate stub for StructuremapMvc: type is sealed. : Cannot generate shim for IUnitOfWork: type is an…
Tinu
  • 695
  • 7
  • 12
11
votes
1 answer

Designing a Nuget Package with Dependency Injection

We are currently writing a nuget package that acts as a service gateway. Its responsibility is to wrap up the call to an external service, so that is made in the correct way and the response is dealt with correctly. Its aim is to reduce the dev time…
Nick
  • 6,366
  • 5
  • 43
  • 62
11
votes
2 answers

Where should I store a reference to my DI container?

I'm wondering how I should store/reference my dependency injection container(s). Is it alright to have a container be a static property on a static class? Or should I have the container be an instance variable on the application? I'm wondering what…
11
votes
3 answers

NHibernate and Structure Map

So I really like working with NHibernate but always used Spring.Net with it. I recently came across StructureMap by Jeremy Miller and really like it better than Spring.Net. On his StructureMap site he promises an example on how to use NHibernate…
dionysus55
  • 149
  • 1
  • 8
11
votes
1 answer

Dependency Injection and development productivity

Abstract For the past few months I have been programming a light weight, C# based game engine with API abstraction and entity/component/scripting system. The whole idea of it is to ease the game development process in XNA, SlimDX and such, by…
edvaldig
  • 2,301
  • 16
  • 17
10
votes
4 answers

StructureMap controller factory and null controller instance in MVC

I'm still trying to figure things out with StructureMap and one of the issues i'm running into is my Controller Factory class blowing up when a null controller type is passed to it. This only happens when the application builds for the first time,…
Sergey
10
votes
4 answers

IoC, Dll References, and Assembly Scanning

Although this question is related to StructureMap, my general question is: When wiring up components with an IoC container in code (as opposed to configuring via xml) do you generally need explicit project/build references to all…
Jeffrey Knight
  • 5,888
  • 7
  • 39
  • 49
10
votes
3 answers

Dependency Injection what´s the big improvement?

Currently I'm trying to understand dependency injection better and I'm using asp.net MVC to work with it. You might see some other related questions from me ;) Alright, I'll start with an example controller (of an example Contacts Manager asp.net…
10
votes
3 answers

Telling StructureMap to use another Constructor

I have a class with 2 constructors. MyClass() and MyClass(IMyService service) How do I tell StructureMap then whenever I do a 'new MyClass()' it should actually call the second constructor and not the first constructor. Please help.
Gautam Jain
  • 6,789
  • 10
  • 48
  • 67
10
votes
2 answers

Does Structuremap support Lazy out of the box?

Does structuremap allow you to do constructor injection in a lazy fashion? Meaning not creating the object which is injected until it is used?
10
votes
1 answer

StructureMap DBServiceRegistry and MVC-mini-profiler?

If I use this code in each Repository class then I get SQL profiling to work but I want to move that code from each class into the class where StructureMap handles the DB. Example of a Repository class: public DB CreateNewContext() { var…
KevinUK
  • 5,053
  • 5
  • 33
  • 49
10
votes
2 answers

StructureMap is not disposing data context when using HttpContextScoped()

My goal is to have one data context (MainDbContext) per HTTP request in ASP.NET MVC and dispose the data context when the request ends. I'm using the following StructureMap configuration: public static class ContainerConfigurer { public static…
devuxer
  • 41,681
  • 47
  • 180
  • 292