Derik Whittaker



Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
Notes from upgrading from StructureMap 2.4.9 to StructureMap 2.5.0

Tonight I updated the Dimecasts codebase from the 2.4.9 version of StructureMap to 2.5.0 and ran into few scenarios where some 'hefty' changes were required.  I thought I would share the 2 major areas that needed change.

Adding named concrete instances for a given interface:




ForRequestedType().AddInstances( x =>
                                        x.OfConcreteType().WithName( "DotNetKicks" );
                                        x.OfConcreteType().WithName( "DZone" );
                                        x.OfConcreteType().WithName( "Digg" );
                                        x.OfConcreteType().WithName( "ShareThis" );


Registering Registry's at application startup:


StructureMapConfiguration.AddRegistry( new IoCWebRegistration() );


ObjectFactory.Initialize( scanner =>
		scanner.AddRegistry( new IoCWebRegistration() );
		scanner.AddRegistry( new IoCDomainRegistration() );
		scanner.AddRegistry( new IoCRepositoryRegistration() );} 

 Till next time,

[----- Remember to check out DimeCasts.Net -----]

Posted 10-21-2008 8:52 PM by Derik Whittaker
Filed under:



Steven Harman wrote re: Notes from upgrading from StructureMap 2.4.9 to StructureMap 2.5.0
on 10-21-2008 10:49 PM


Why register the registries explicitly as opposed to just scanning for them?

Derik Whittaker wrote re: Notes from upgrading from StructureMap 2.4.9 to StructureMap 2.5.0
on 10-22-2008 6:12 AM


The main reason I do not use the 'scan' feature is because I would rather register everything explicitly.  If all things are equal I always lean towards making code more explicit rather then less.

Also, In the eyes of many there is already enough 'black magic' in IoC containers and having the framework 'just find' registries would be considered 'magic'.  -- Not saying that I believe this is magic, but some do.

With all that being said, you do have a valid point.  I could simply tell SM to scan and be done with it.  That is a valid option.

Nick berardi wrote re: Notes from upgrading from StructureMap 2.4.9 to StructureMap 2.5.0
on 10-22-2008 8:19 AM

Is there any reason they made the interface more verbose?  Or was that you making more explicit code, like you were explaining to Steve?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)