title: Ninject + Auto Discovery
body: <p>Here's the deal: I want to create a C# console app.  When run, this app will look in a particular folder for dll's with classes that implement a particular interface, and then run a method on those dll's.</p>
  
  <p>I haven't done this before but from my reading that should be "easy enough" from an IoC/Ninject perspective.  I think you can do something with <code>kernel.Bind()</code> to load assemblies of a certain interface in a certain directory.  I think/hope I can figure that part out (if you know otherwise, please do tell!).</p>
  
  <p>But here is my quandary.</p>
  
  <p>Here is a visual to help first:</p>
  
  <pre><code>MainProgramFolder
  -- MainProgram.exe
  -- MainProgram.exe.config
  -- LibraryFolder
  ----- Library1Folder
  --------Library1.dll
  --------Library1.dll.config
  ----- Library2Folder
  --------Library2.dll
  --------Library2.dll.config
  </code></pre>
  
  <p>The dll's that implement this interface are technically stand alone apps -- they are just libraries instead of exe's (or, rather, I'd like them to be for IoC purposes).  I'd like for them to be run in their own context, with their own app.configs.  So for example, MainProgram.exe would bind the ILibrary interface to classes inside Library1.dll and Library2.dll because they implement ILibrary.  But <em>inside</em> Library1, it calls ConfigurationManager to get its settings.  When I call Class.Method() for each of the bindings from MainProgram, how can I ensure they are referencing their own .config's and not MainProgram.exe.config?  (Also, fwiw, these additional libraries will likely not be a part of the assembly or even namespace of the main programs -- we're basically providing a drop folder for an application to kind of "subscribe" to the main program's execution.)</p>
  
  <p>IOW, I know you can attach an app.config to a class library but I wouldn't know how, after the bindings have been resolved from the IOC, to make those dll's "see" its own config rather than the main program's config.</p>
  
  <p>All thoughts appreciated!</p>
  
  <p>Thanks
  Tom</p>