title: Autofac IoC GetInstance method
body: <p>I'm trying to use autofac in my project. So in Mef i could get the instance of an interface with this code: </p>
  
  <pre><code>private static CompositionContainer _container;
  
          public static void Initialize()
          {
              string path = AppDomain.CurrentDomain.BaseDirectory.Contains(@"\bin") ?
                  AppDomain.CurrentDomain.BaseDirectory :
                  Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin");
  
              //DirectoryCatalog catalog = new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"), "*.Data*.dll");
              DirectoryCatalog catalog = new DirectoryCatalog(path, "*.dll");
              _container = new CompositionContainer(catalog);
              _container.ComposeParts();
          }
  
          private static void CheckContainer()
          {
              if (_container == null)
              {
                  Initialize();
              }
          }
  
          public static T GetInstance&lt;T&gt;()
          {
              CheckContainer();
  
              return _container.GetExportedValue&lt;T&gt;(); 
          }
  </code></pre>
  
  <p>But autofac seems confusing to me... How can i add this feature to my app using autofac?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>I changed that code to this:</p>
  
  <pre><code>private static ContainerBuilder _container;
          private static IContainer container;
  
          public static void Initialize()
          {
              _container = new ContainerBuilder();
              var logging = Assembly.Load("StarlightFramework.Logging");
              _container.RegisterAssemblyTypes(logging);
              container = _container.Build();
  
          }
  
          public static T GetInstance&lt;T&gt;()
          {
              if(container == null)
                  Initialize();
              return container.Resolve&lt;T&gt;();
          }
  </code></pre>
  
  <p>But i get this error this time: "Could not load file or assembly 'Autofac, Version=2.6.1.841, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. "</p>
  
  <p>What might be the problem?</p>