title: Why would System.Type.GetType("Xyz") return null if typeof(Xyz) exists?
body: <p>I have come across a strange behaviour in my (huge) .NET 4 project. At some point in the code, I am referring to a fully qualified type, say:</p>
  
  <pre><code>System.Type type = typeof (Foo.Bar.Xyz);
  </code></pre>
  
  <p>later on, I do this:</p>
  
  <pre><code>System.Type type = System.Type.GetType ("Foo.Bar.Xyz");
  </code></pre>
  
  <p>and I get back <code>null</code>. I cannot make sense of why this is happening, because my type name is correct, and I have checked with other types and they get resolved properly. Moreover, the following LINQ query finds the type:</p>
  
  <pre><code>var types = from assembly in System.AppDomain.CurrentDomain.GetAssemblies ()
              from assemblyType in assembly.GetTypes ()
              where assemblyType.FullName == typeName
              select assemblyType;
  
  System.Type type = types.FirstOrDefault ();
  </code></pre>
  
  <p>Are there any reasons why <code>System.Type.GetType</code> could fail?</p>
  
  <p>I have finally had to resort to this piece of code instead of <code>GetType</code>:</p>
  
  <pre><code>System.Type MyGetType(string typeName)
  {
      System.Type type = System.Type.GetType (typeName);
  
      if (type == null)
      {
          var types = from assembly in System.AppDomain.CurrentDomain.GetAssemblies ()
                      from assemblyType in assembly.GetTypes ()
                      where assemblyType.FullName == typeName
                      select assemblyType;
  
          type = types.FirstOrDefault ();
      }
  
      return type;
  }
  </code></pre>