In the C # programming process, the Type. GetType (string) method is used to obtain the corresponding Type of a string. However, the search for this string is not in all programming sets and referenced assembly. Therefore, you need to write one by yourself.
/// <Summary> /// type search for the running and referenced assembly /// </summary> /// <param name = "type"> </param>/ // <returns> </returns> private static Type GetTypeFromAssembly (string type) {var x = Type. getType (type, false, true); if (x! = Null) return x; var executingAssembly = Assembly. GetExecutingAssembly (); x = executingAssembly. GetType (type); if (x! = Null) return x; var assNames = executingAssembly. getReferencedAssemblies (); foreach (var name in assNames) {if (name. fullName. startsWith ("System", StringComparison. ordinalIgnoreCase) | name. fullName. startsWith ("mscorlib", StringComparison. ordinalIgnoreCase) continue; var assembly = Assembly. load (name); x = assembly. getType (type); if (x! = Null) return x;} return null; throw new TypeLoadException (string. Format ("No {0} type is found in all running programs. ", Type ));}