I also hit this problem and realized that, especially in ASP.Net with JIT compilation, I do not always know the Assembly information. I added the following to my ReflectionUtilities class. It is a "sledgehammer to crack a nut" to some degree but it works with both the AssemblyQualifiedName and the basic class FullName. The first basically short-circuits the search of the CurrentDomainAssemblies that must otherwise occur.
public static Type FindType(string qualifiedTypeName)
{
Type t = Type.GetType(qualifiedTypeName);
if (t != null)
{
return t;
}
else
{
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
t = asm.GetType(qualifiedTypeName);
if (t != null)
return t;
}
return null;
}
}
Note: Given Reflection performance issues this should not be called inside loops without the assembly qualification if at all possible. Better to access the first item you need, extract the assembly information from that, and procede from there. Not always appropriate but much more efficient (if anything in Reflection can be called efficient:-)).
Alistair