protected Type GetTypeFromName(string typeName)
{
if (typeName == null || typeName.Length == 0)
{
return null;
}
// try the generic method.
Type typeFromGetType = Type.GetType(typeName);
// If we didn't get a type from the generic method, or if the assembly we found the type
// in is the same as our Component's assembly, use or Component's assembly instead. This is
// because the CLR may have cached an older version if the assembly's version number didn't change
// See VSWhidbey 560732
Type typeFromComponent = null;
if (ComponentType != null)
{
if ((typeFromGetType == null) ||
(ComponentType.GetTypeInfo().Assembly.FullName.Equals(typeFromGetType.GetTypeInfo().Assembly.FullName)))
{
int comma = typeName.IndexOf(',');
if (comma != -1)
typeName = typeName.Substring(0, comma);
typeFromComponent = ComponentType.GetTypeInfo().Assembly.GetType(typeName);
}
}
return typeFromComponent ?? typeFromGetType;
}