Using Type.GetType(typeName)
If no assembly is specified, Type.GetType() will only look in the calling assembly and then mscorlib.dll for the type. For it to look in any other assembly, you need to give the Type.AssemblyQualifiedName for the type. For example:
Type.GetType("System.Uri, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
This is because part of the type identity is its assembly. We don't check for it in all of the assemblies in the appdomain because (a) that would be bad for performance and (b) it's legal to use multiple types with the same name, but from different assemblies. In that case, we wouldn't know which one is the right one to return. So, it's always required to specify the assembly or else we will only make limited guesses.
Of course, if you would rather not supply the assembly display name, you can call Assembly.GetType() or typeof() instead.
Comments
Anonymous
June 07, 2004
The comment has been removedAnonymous
February 20, 2006
Hello,
Is it possible to load a Type which is located in an assembly which is not in the bin folder from the value previously retrieved from Type.AssemblyQualifiedName.
Ex :
/webapp/plugins/TestPlugin1.dll
load the Class1 into TestPlugin1.dll
from the string
TestPlugin1.Class1, TestPlugin1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Thanks in advance for your help
ChristopheAnonymous
June 27, 2006
The royal WE is being used above indicating your on that team that owns this feature. Shouldn't the above comments be part of the docs on msdn? I don't seem to see them http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassgettypetopic1.aspAnonymous
July 18, 2008
Dear (royal) Suzanne This post was very helpful for me. Now, in this second, I debug my Visual Studio Package and have this assembly layout: Package --> Language --> BunnyCore.dll in GAC !!! In the Language assembly I say Type t = Type.GetType("Carrots.Bunny"); so fulltypename but no assembly is given, and I get back the correct type that refers to the assembly in the GAC !?? Considering your (reasonable) algorithm above, I should get null. Thank you for clarification.Anonymous
March 17, 2009
Have you already considered the RowEditTemplate and Templated Column features but would rather use a