title: Why can't I get Type.GetType() to find the type of my plugin instance referenced in app.config?
body: <p>So here's the deal.  I've got my solution which has a few projects in it:</p>
  
  <ul>
  <li>A wrapper project - this is just a console app that's currently standing in for a windows service during debugging.</li>
  <li>A worker project - this contains the guts of the code.  This way I can easily debug the code for the windows service without the headache.  </li>
  <li>A plugin library project - This contains a plugin factory to new up a concrete instance of a plugin.</li>
  <li>A plugin project - This contains a concrete implementation of my plugin.</li>
  </ul>
  
  <p>My wrapper application contains my app.config which my plugin should reference directly for self configuration.  This way my wrapper application doesn't need to know anything other than it needs to call the adapter factory to new up the instance of the plugin.</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="Plugin" value="Prototypes.BensPlugin" /&gt;
      &lt;add key="Prototypes.BensPlugin.ServiceAddress" value="http://localhost/WebServices/Plugin.asmx" /&gt;
      &lt;add key="Prototypes.BensPlugin.Username" value="TestUserName" /&gt;
      &lt;add key="Prototypes.BensPlugin.Password" value="TestPassword" /&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Wrapper project:</p>
  
  <pre><code>using Worker;
  
  public class Program
  {
      public static void Main()
      {
          var serviceProc = new ServiceProcess();
          serviceProc.DoYourStuff();
      }
  }
  </code></pre>
  
  <p>Worker project:</p>
  
  <pre><code>using PluginLibrary;
  
  namespace Worker
  {
      public class ServiceProcess
      {
          public string GetRequiredAppSetting(string settingName)
          {
              /* Code to get a required configuration setting */
          }
  
          public void DoYourStuff()
          {
              string pluginTypeName = GetRequiredAppSetting("Plugin"); 
              //At this point, pluginTypeName = "Prototypes.BensPlugin"
              Type type = Type.GetType(pluginTypeName); //type == null, wth!?
  
              //string testTypeName = new BensPlugin().GetType().ToString();
              ///At this point, testTypeName = "Prototypes.BensPlugin"
              //Type testType = Type.GetType(testTypeName)
              ///And testType still equals null!
  
              if (type != null)
              {
                  IPlugin plugin = PluginFactory.CreatePlugin(type);
                  if (plugin != null)
                  plugin.DoWork();
              }
          }
      }
  }
  </code></pre>
  
  <p>Plugin library:</p>
  
  <pre><code>namespace PluginLibrary
  {
      public interface IPlugin
      {
          void DoWork();
      }
  
      public class PluginFactory
      {
          public IPlugin CreatePlugin(Type pluginType)
          {
              return (IPlugin)Activator.CreateInstance(pluginType);
          }
      }
  }
  </code></pre>
  
  <p>Plugin:</p>
  
  <pre><code>using PluginLibrary;
  
  namespace Prototypes
  {
      public class BensPlugin : IPlugin
      {
          public string ServiceAddress { get; protected set; }
          public string username { get; protected set; }
          public string password { get; protected set; }
  
          public void DoWork()
          {
              Trace.WriteLine("Ben's plugin is working.");
          }
  
          public BensPlugin()
          {
              /* Code to self configure from app.config */
          }
      }
  }
  </code></pre>
  
  <p>Okay, so that sets the stage.  Where I'm coming unstuck is in my worker project when I reference <code>Type.GetType(pluginTypeName)</code>.  My <code>pluginTypeName</code> is being pulled from the configuration correctly, but <code>Type.GetType(pluginTypeName)</code> returns <code>null</code>.  I've tried newing up an instance of my plugin directly at that same place in the code:</p>
  
  <pre><code>var obj = new BensPlugin();
  </code></pre>
  
  <p>This works just fine, and <code>obj.GetType().ToString()</code> returns the exact same string as I have configured in the <code>app.config</code>.</p>
  
  <p>Can anyone tell me why I can new up a concrete object at that point in the code, but <code>Type.GetType(pluginTypeName)</code> would fail?</p>