<p>After attending a recent Alt.NET group on IoC, I got to thinking about the tools available and how they might work.  <code>StructureMap</code> in particular uses both attributes and bootstrapper concepts to map requests for <code>IThing</code> to <code>ConcreteThing</code>.  Attributes automatically throw up flags for me that either reflection or IL injection is going on.  Does anyone know exactly how this works (for <code>StructureMap</code> or other IoC tools) and what the associated overhead might be either at run-time or compile-time?</p>

[{'answer_id': 58004, 'author': 'tgeros', 'author_id': 4458, 'author_profile': 'https://Stackoverflow.com/users/4458', 'pm_score': 1, 'selected': False, 'text': "<p>I can't say much for other IoC toolkits but I use Spring.Net and have found that there is a one off initial performance penalty at startup. Once the container has been configured the application runs unaffected.</p>\n"}, {'answer_id': 58025, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 0, 'selected': False, 'text': '<p>They major problem is that code becomes hard to understand. It might become <em>pure magical</em> if one overuse IoC. Another problem is performance. In most cases performance lost is not noticeable. But when you start creating most of your objects via IoC container, it can suddenly drop below ocean level.</p>\n'}, {'answer_id': 58994, 'author': 'Darren', 'author_id': 6065, 'author_profile': 'https://Stackoverflow.com/users/6065', 'pm_score': 1, 'selected': False, 'text': '<p>I use Windsor from the <a href="http://castleproject.org" rel="nofollow noreferrer">CastleProject</a> and have found it immensely useful in reducing dependencies. I haven\'t noticed a performance issue yet but one thing I do find is that the configuration can get a bit cumbersome. To help in this regard I\'m starting to look at Binsor, which is a DSL for Windsor written in boo.</p>\n\n<p>Another thing to be aware of is that when navigating code you wont be able to go to the code that will be executing at runtime.</p>\n'}, {'answer_id': 184830, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>I built a very lightweight and basic <a href="http://blogs.microsoft.co.il/blogs/shay/archive/2008/09/30/building-custom-object-mapper.aspx" rel="nofollow noreferrer">IOC</a>, here:</p>\n\n<p><a href="http://blogs.microsoft.co.il/blogs/shay/archive/2008/09/30/building-custom-object-mapper.aspx" rel="nofollow noreferrer">http://blogs.microsoft.co.il/blogs/shay/archive/2008/09/30/building-custom-object-mapper.aspx</a></p>\n\n<p>It\'s not an alternative to the libraries You mentioned but if all that You need is to resolve a type by giving its interface it might be a perfect solution.</p>\n\n<p>I don\'t handle instantiation types (singleton, transient, thread, pool...), all object will be instantiated as  singletons, you call it like:</p>\n\n<pre><code>IRepository _repository = ObjectFactory.BuildFactory&lt;IRepository&gt;();\n</code></pre>\n\n<p>Shay</p>\n'}]
['https://Stackoverflow.com/questions/57990', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4541/']