How Type.GetType works when given partially qualified type name?

If the assembly has been loaded in the current domain then the code below usually works:

public static Type GetTypeEx(string fullTypeName)
{
    return Type.GetType(fullTypeName) ??
           AppDomain.CurrentDomain.GetAssemblies()
                    .Select(a => a.GetType(fullTypeName))
                    .FirstOrDefault(t => t != null);
}

You can use it like so:

Type t = GetTypeEx("System.Net.Sockets.SocketException");

Leave a Comment