Questions tagged [structuremap3]

Version 3 of the StructureMap Dependency Injection / Inversion of Control library for .NET

Home page: https://structuremap.github.io/

What’s Different and/or Improved in StructureMap 3?

Details taken from http://jeremydmiller.com/2014/03/31/structuremap-3-0-is-live/

  • The diagnostics and exception messages are much more useful
  • The registration DSL has been greatly streamlined with a hard focus on consistency throughout the API
  • The core library is now PCL compliant and targets .Net 4.0. So far SM3 has been successfully tested on WP8
  • Removed strong naming from the public packages to make the world a better place.
  • Nested container performance and functionality is vastly improved (100X performance in bigger applications!)
  • Xml configuration and the ancient attribute based configuration has been removed.
  • Interception has been completely rewritten with a much better mechanism for applying decorators (a big gripe of mine from 2.5+)
  • Resolving large object graphs is faster
  • The Profile support was completely rewritten and more effective now
  • Child containers (think client specific or feature specific containers)
  • Improvements in the usage of open generics registration for Jimmy Bogard
  • Constructor function selection and lifecycle configuration can be done per Instance (like every other IoC container in the world except for SM < 3.0)
  • Anything that touches ASP.Net HttpContext has been removed to a separate StructureMap.Web nuget.
  • Conventional registration is more powerful now that the configuration model is streamlined and actually useful as a semantic model

Related

118 questions
4
votes
1 answer

What do I do when ASP.NET 5 (vNext) can't redirect bindings?

I am just getting my feet wet with MVC 6. I installed VS 2015 and with the default ASP.NET 5 preview MVC Web Application template everything runs fine under local IIS. I then tried to switch out the Default DI container with StructureMap following…
4
votes
1 answer

How to register an optional decorator or decorator with optional parameters using structuremap asp.net mvc?

I have implemented a CQRS approach in my application heavily influenced by this fantastic article: https://cuttingedge.it/blogs/steven/pivot/entry.php?id=9. My code for the commands and handlers is set it up identically to the article and that part…
ryanulit
  • 4,983
  • 6
  • 42
  • 66
4
votes
3 answers

How to replace ObjectFactory usage in StructureMap 3

At present we use StructureMap v2.6 for our dependency injection and our setup is like this: In the Application_Start we have: DependencyResolver.SetResolver(new StructureMapDependencyResolver(IoC.Initialize())); And the Initialize method is…
Gaz
  • 1,249
  • 3
  • 19
  • 37
4
votes
2 answers

Constructor Dependency Injection WebApi Attributes

I have been looking around for a non Parameter injection option for the WebApi attributes. My question is simply whether this is actually possible using Structuremap? I have been googling around but keep coming up with either property injection…
3
votes
1 answer

StructureMap: The name 'ObjectFactory' does not exist in the current context

I am using StructureMap to resolve dependency, which works fine with older version.But after updating StructureMap version 4.2.0.40, i am facing this error. ObjectFactory is now obsoleted in new version. So how to modify below logic to fit this with…
3
votes
0 answers

StructureMap Argument out of range by Generic Interfaces

I have a strange problem with following structuremap configuration example: IReturnValue public interface IReturnValue { } IService public interface IService where T : IReturnValue { void Execute(); } with two…
3
votes
1 answer

Decorator Interception with Open Generics in StructureMap 3

I have a project that is using a decorator convention to wrap command handlers with logging decorators via interception of open generic types in StructureMap 2.6. However, I'm having difficulty figuring out the best way to implement the equivalent…
Matthew Renze
  • 634
  • 1
  • 6
  • 17
3
votes
0 answers

Bootstrap StructureMap.WebApi2 from OWIN self host WepAPI2

I have a WebAPI project that I am self hosting from an integration test suite project so that the tests will setup and tear down the WebAPI app in process, following these…
Myles McDonnell
  • 12,943
  • 17
  • 66
  • 116
3
votes
0 answers

Value cannot be null. Parameter name: httpContext for StructureMap.WebApi2 in Web API2 project

I have used StructureMap.WebApi2 nuget package for Web API 2 project. The Web API controllers use constructor injection to inject a repository dependency which should be resolved by StructureMap Ioc.. Now when I try to run the project I am always…
santosh kumar patro
  • 7,231
  • 22
  • 71
  • 143
3
votes
2 answers

How do I use Structuremap 3 with objects that aren't friendly to constructor injection?

I'm moving from StructureMap 2.x to 3.x. One major change is that using ObjectFactory results in the following warning: 'StructureMap.ObjectFactory' is obsolete: 'ObjectFactory will be removed in a future 4.0 release of StructureMap. Favor the …
Josh Kodroff
  • 27,301
  • 27
  • 95
  • 148
3
votes
0 answers

StructureMap: passing arguments to a selected constructor

My StructureMap configuration looks like this: container.Configure(x => x.For().Use().SelectConstructor(() => new FileStreamWrap("", System.IO.FileMode.Open)); I'm trying to get an instance of FileStreamWrap and passing…
cortex42
  • 234
  • 1
  • 13
3
votes
1 answer

How to invoke HybridHttpOrThreadLocalScoped in StructureMap 3

I am trying to move from Structuremap 2.6.4.1 to 3.1.4.143 but am unable to figure out how to handle HybridHttpOrThreadLocalScoped. None of the SO Q/A I can find seems to work for me... I have the following code: using StructureMap; using…
MatiasK
  • 686
  • 1
  • 7
  • 20
3
votes
1 answer

Structuremap 3 constructor that accepts list of all registered types/instances

I have an object which expects an IEnumerable as a parameter to it's constructor. I also have a line in my container configuration which adds all implementers of IPluginType: x.Scan(s => { ... …
A. Murray
  • 2,761
  • 5
  • 27
  • 40
3
votes
2 answers

How to tell StructureMap 3 to use specific constructor for specific type?

I am using StructureMap (version 3.1.4.143) for general dependency resolution in my Web API project, and it's working fine so far. I want structuremap to follow it's default behavior of selecting the constructor with most parameters. However, for a…
Arghya C
  • 9,805
  • 2
  • 47
  • 66
3
votes
2 answers

StructureMap 3 get requested type

I have the following StructureMap registrations that work in version 2.6.4 and I'm finally upgrading to the latest SM (3.1.2 as of this writing). And need to update it since there doesn't appear to be a IContext.BuildStack anymore. Here is the old…
Jeff Treuting
  • 13,910
  • 8
  • 36
  • 47