title: How to replace ObjectFactory usage in StructureMap 3
body: <p>At present we use StructureMap v2.6 for our dependency injection and our setup is like this:</p>
  
  <p>In the Application_Start we have:</p>
  
  <pre><code>DependencyResolver.SetResolver(new StructureMapDependencyResolver(IoC.Initialize()));
  </code></pre>
  
  <p>And the Initialize method is implemented like this:</p>
  
  <pre><code>public static IContainer Initialize() {
          ObjectFactory.Initialize(x =&gt; {
              x.Scan(scan =&gt; { scan.TheCallingAssembly(); scan.WithDefaultConventions(); });
  
            x.For&lt;IFoo&gt;().Use(() =&gt; new Foo());
  
          });
          return ObjectFactory.Container;
      }
  }
  </code></pre>
  
  <p>Throughout our code we have several places that use <code>ObjectFactory.GetInstance&lt;IFoo&gt;()</code> rather than using constructor injection. With v3 of StructureMap this has been marked as obsolete, so my question is how do we achieve the same thing with the latest version. </p>