title: Custom config section: Could not load file or assembly
body: <p>I'm having a very hard time trying to access a custom configuration section in my config file.</p>
  
  <p>The config file is being read from a .dll that is loaded as a plug-in. I created the Configuration and necessary code using the <a href="http://www.codeplex.com/csd" rel="noreferrer">Configuration Section Designer</a> VS addin.</p>
  
  <p>The namespace is 'ImportConfiguration'. The ConfigurationSection class is 'ImportWorkflows'. The assembly is ImportEPDMAddin.</p>
  
  <p>The xml:</p>
  
  <pre><code>  &lt;configSections&gt;
      &lt;section name="importWorkflows" type="ImportConfiguration.ImportWorkflows, ImportEPDMAddin"/&gt;
    &lt;/configSections&gt;
  </code></pre>
  
  <p>Whenever I try to read in the config, I get the error:</p>
  
  <p>An error occurred creating the configuration section handler for importWorkflows: Could not load file or assembly 'ImportEPDMAddin.dll' or one of its dependencies. The system cannot find the file specified.</p>
  
  <p>The dll will not reside in the same directory as the executable as the software that loads the plugin places the dll and it's dependencies in it's own directory. (I can't control that.)</p>
  
  <p>I edited the code for the singleton instance to the following:</p>
  
  <pre><code>string path = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
  path = path.Replace("file:///", "");
  System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(path);
  return configuration.GetSection(ImportWorkflowsSectionName) as ImportConfiguration.ImportWorkflows;
  </code></pre>
  
  <p>I have also tried using a simple NameValueFileSectionHandler as well, but I get an exception saying that it can't load file or assembly 'System'.</p>
  
  <p>I have read numerous blog posts and articles and it sounds like it is possible to read a config file in for a dll, but I just can't get it to work. Any ideas? Thanks.</p>