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

How to see the error in controller constructor when using StructureMap?

I am using StructureMap 3 with MVC 5. The problem is that whenever an exception happens in the controller constructor I get a misleading StructureMap error instead of the actual error. For example I have the following controller: public class…
3
votes
2 answers

cannot resolve symbol SetAllProperties in StructureMap.Net4

In my project i am using structureMap.Net4 (version 3.0.3) with StructureMap (3.0.3) . I configured the Ioc with following code for setter injection public static IContainer Initialize() { ObjectFactory.Initialize(x => …
Binson Eldhose
  • 993
  • 3
  • 14
  • 35
3
votes
2 answers

Interception Using StructureMap 3.*

I've done interception using Castle.DynamicProxy and StructureMap 2.6 API but now can't do it using StructureMap 3.0. Could anyone help me find updated documentation or even demo? Everything that I've found seems to be about old versions. e.g.…
3
votes
4 answers

StructureMap ObjectFactory.TryGetInstance cannot resolve symbol error

I am getting "Cannot Resolve Symbol Error" for StructureMap ObjectFactory.TryGetInstance But ObjectFactory.GetInstance is okay. StructureMap Version 3. Assembly include is "Using StructureMap;" I am using this in an MVC 5 project. Missing any…
Blue Clouds
  • 7,295
  • 4
  • 71
  • 112
2
votes
0 answers

How to Resolve an Instance in Structuremap RegistrationConvention

I'm using Structuremap as IOC container. In old version of Structremap I used ObjectFactory, now I have updated to Structremap.Mvc5 from below link: https://github.com/webadvanced/Structuremap.MVC5 But I can't create an instance of…
Saeid Mirzaei
  • 950
  • 2
  • 18
  • 48
2
votes
1 answer

StructureMap IoC in Application_Start

I cannot get StructureMap to inject a value into the constructor of the MvcApplication of the Global.asax.cs file. I have created a brand new and clean project and used StructureMap.MVC5 package to generate the necessary structures inside the…
Rok
  • 1,482
  • 3
  • 18
  • 37
2
votes
0 answers

How can I swap out dependencies on a per-request basis and avoid injecting factories?

I'm trying to use StructureMap to swap out implementations at request time based on some aspect of the request (certain combinations of parameters). Some of these dependencies are deeply nested in the object graph. For a number of reasons, I want to…
Ant P
  • 24,820
  • 5
  • 68
  • 105
2
votes
0 answers

System.InvalidOperationException Stack empty when using StructureMap MVC5 package

After installing StructureMap.MVC5 package got next exception System.InvalidOperationException Stack empty. in case when you try to display circular object dependency with partial view. @model WebApplication.Models.Test @foreach (var val in…
2
votes
0 answers

Structuremap version 3, constructor Injection for IEnumerable not working

I have some types like ParentClassA and ParentClassB, with their constructor having parameter as IEumerable, like shown in the code below. public interface IType { } public class TypeA : IType { } public class TypeB :…
Tiju John
  • 933
  • 11
  • 28
2
votes
1 answer

StructureMap GetAllInstances on Open Generic Types

I'm new to StructureMap and trying out a simple scenario I scan for all assemblies in the base folder and look for types implementing my open generic interface. Scan( scan => { scan.AssembliesFromApplicationBaseDirectory(); …
Jay
  • 177
  • 2
  • 12
2
votes
1 answer

How do I use the MoqAutoMocker auto mocker with StructureMap 3?

I'm trying to get familiar with unit testing with StructureMap, and am attempting to use the built-in auto mocker for Moq that appears to come with StructureMap. I installed the NuGet package using the directions Install-Package StructureMap and it…
Sam Storie
  • 4,444
  • 4
  • 48
  • 74
2
votes
1 answer

Passing additional constructor arguments with StructureMap

Following on from my previous posting on how to implement the IContainer in structure map, I have hit what I hope is my last problem for a while. How does one pass additional (non Structuremap injected) objects into a constructor? Lets take the…
Morn
  • 191
  • 1
  • 4
  • 14
2
votes
2 answers

Structuremap 3 multiple decoration

I am trying to create a dependency graph in StructureMap 3 with a chain of decorators: Each instance has a constructor with multiple arugments, but exactly one argument of an inner IGeocoder, e.g. public SomeCachingGeocoder(IGeoCoder inner, IFoo…
Jon Bates
  • 3,055
  • 2
  • 30
  • 48
2
votes
2 answers

How do you configure structuremap.MVC 5 in ASP.NET MVC5 to ignore framework interfaces/class instances

The structuremap method, scan.WithDefaultConventions(); in structuremap.MVC 5 assumes the convention IMyClassName , MyClassName for Dependency Injection. This is okay if you have only classes you created. With ASP.NET MVC 5 application out of the…
2
votes
3 answers

How to use Auto Registration and Type Scanning in Structuremap

In my solution I have three projects like this. I copy Common.dll and Service.dll in a folder like d:\libs and use the below code with type scan ObjectFactory.Initialize(x => { x.Scan(xx => { …
M.Azad
  • 3,673
  • 8
  • 47
  • 77