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

StructureMap in ASP.NET Web API 2 without a reference to System.Web.Mvc

The StructureMap.WebApi2 package has a dependency to StructureMap.MVC5 which in return has a dependency to System.Web.Mvc. As we are building a Web API-only project we don't want to include the System.Web.Mvc assembly. Is it possible to use…
adamfinstorp
  • 1,627
  • 3
  • 17
  • 26
2
votes
2 answers

Structuremap all instances of abstract

Using Net 4.5.1 and StructureMap 3.1.4 I have services that extending an abstract class: public abstract class Charting { protected readonly String baseConfigurationString; public Charting(String baseConfigurationString) { …
Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
2
votes
1 answer

Structuremap3 DecorateAllWith

I've been struggling getting DecorateAllWith working on generic interfaces. I've read some posts here where they solved it using interceptors but they seem to be using an older structure map version and it doesn't seem like a "clean" solution. I…
Niclas
  • 217
  • 3
  • 9
2
votes
0 answers

Swapping nested dependency when requesting a specific object in StructureMap 3

I am trying to swap a nested dependency when resolving a specific instance using StructureMap. In 2.x I was able to do this with the following UseSpecial code, but it does not work in 3.x The code is basically saying... when requesting an instance…
Jon Erickson
  • 112,242
  • 44
  • 136
  • 174
2
votes
1 answer

Which Lifecycle Replaces the old HybridLifecycle?

Which Structuremap v3 Lifecycle is recommended to replace the old HybridLifecycle? Specifically for a UnitOfWork in a web app environment?
mxmissile
  • 11,464
  • 3
  • 53
  • 79
1
vote
2 answers

Injecting IHttpClientFactory in structuremap

We are using an older version of Structuremap (3.1.9.463). It's been a while since I used structuremap and HttpClients alongside and I wonter how to properly inject the IHttpClientFactory in structuremap. Simply using…
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
1
vote
1 answer

InterceptWith() in StructureMap 3.x

Hi all, currently I'm trying to translate a part of code from SM 2.X to SM 3.X, but still have some problems with the interception part. Maybe someone more familiar with StructureMap can help me with that? container.IfTypeMatches(type =>…
1
vote
1 answer

TypeInterceptor replacement for Structuremap 3

Can't seem to find any useful guide on how to reproduce the functionality currently provided by a TypeInterceptor in my codebase when upgrading from StructureMap 2 to version 3 (can't upgrade to v4 as we aren't using .NET 4.6 yet). Essentially what…
Will Appleby
  • 476
  • 4
  • 17
1
vote
1 answer

NHibernate + Structuremap + TransactionScope

I was wondering if someone can suggest the best pattern to use in the above scenario, assuming that A) StructureMap is used in the following way: cfg.For() .LifecycleIs(new TransientLifecycle()) …
Rok
  • 1,482
  • 3
  • 18
  • 37
1
vote
2 answers

Testing code in a custom NancyFx Bootstrapper

I have a custom Nancy Bootstrapper which uses StructureMapNancyBootstrapper but the issue is the same regardless of container. public class CustomNancyBootstrapper : StructureMapNancyBootstrapper { protected override void…
alexs
  • 1,507
  • 18
  • 17
1
vote
1 answer

Structuremap 3+ (3.1.6.186) how to specify a default instance?

I'm convering from old structure map to a new one.. 2. something to 3.1.6.186... I'm trying to define a default instance for IWebAccess as WinFormAccess...when run it I get this error: SetUp : StructureMap.StructureMapConfigurationException : No…
Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97
1
vote
1 answer

What is the equivalant of the following Ninject statement in Structuremap

What is the equivalent of the following in Structuremap kernel.Bind().To(); kernel.Bind().To(); kernel.Bind(x => x .FromAssembliesMatching("MyApp.dll") …
Indu
  • 95
  • 2
  • 8
1
vote
0 answers

Structuremap, call SetProperty for all instances derived from a class

What's the best way in StructureMap 3 to apply SetProperty to all interfaces deriving from a particular class? I have many, many classes of the form public class FooBarProxy : Proxy, IFooBarProxy { public string BaseAddress { get; set; } } I…
stevieg
  • 652
  • 4
  • 14
1
vote
0 answers

Owin, WebApi 2, and Structuremap 3 throws Null HttpContext exception

I'm trying to get StructureMap 3 to work with WebAPI 2 self-hosted in OWIN. Has anyone been successful in getting this to work? I installed StructureMap 3, WebAPI 2.2, Owin Self Host, and StructureMap.WebApi2 from Nuget. Then in the WebApi service…
Matthew Renze
  • 634
  • 1
  • 6
  • 17
1
vote
1 answer

Cannot access a disposed object.\r\nObject name: 'DataContext accessed after Dispose'

I am using StructureMap.WebApi2 nuget package for Web API 2 project for managing the depedency injection. In the DefaultRegistry.cs class I have mentioned all the dependencies required Nested container is used for each…